I would like to have a CI job which executes in merge requests if that merge request changes certain files. It appears to me if I set rules:changes, it only checks whether the most recent commit edits those files, rather than anything in the branch being merged. I see in the documentation that is supported with “only:changes” (GitLab CI/CD pipeline configuration reference | GitLab) but this is unavailable to me because I use rules elsewhere.
Is there a way to achieve this using rules:changes?
This is not the expected behavior. The rules:changes evaluates all paths expressed in a merge request diff, i.e. the same set of files you see in the tree on the Merge Request’s Changes tab.
Do you have a sample project, or perhaps a list of steps that demonstrates your observed behavior?
Could you please also share relevant portions of the CI pipeline config in use on the project?
It appears my diagnosis was incorrect. After some more prodding, I see now that my issue is the old version of gitlab. I was trying to use a variable in the changes field (something like rules: changes: $SOURCEDIR/**/*), but support for this was only added in 13.6.
I was searching for such an explanation in the documentation (here and here and here) and didn’t find it. I could only run certain jobs based only on paths in the last commit before moving to rules. This is a significant change when migrating jobs from only/except to rules logic and if only is to become deprecated, I believe there should be some logic to replace it.