Problem to solve
How can I configure my GitLab pipeline to prevent triggering when there’s a change in the gitlab-ci.yml file, but trigger it for changes in other files within my repository? Additionally, if there are changes in any file along with changes in gitlab-ci.yml, I want the pipeline to trigger as well.
Configuration
I tried:
workflow:
rules:
- changes:
- .gitlab-ci.yml
when: never
- if: ('$CI_PIPELINE_SOURCE == "merge_request_event"') ||($CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == 'develop') || ($CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == 'main') || ($CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == 'feature/gcd-21')
when: always
It works fine for the two first cases, but if there are changes in the gitlab-ci.yml and other files in the repository, the pipeline does not trigger