I have a job in my .gitlab-ci.yaml
file with the following rules:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- src/**/*
- if: $CI_COMMIT_BRANCH
changes:
- src/**/*
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
I was expecting it to only run in two scenarios:
- on any commit made to an open merge request
- on any commit to a branch, but only if the MR was not yet open (trying to avoid duplicate runs)
And specifically, only when files inside my source code folder were changed. And this is the part that doesn’t seem to be working for me. I just made a commit to a feature branch adding new files to a new folder at the root of the repository. I made no changes to the source code directory. But this job fired on that branch commit. Can anyone decipher why?
It’s been a few months, so I don’t remember where I got this rules block from, but it was informed by research I did here on SO. And not that I think it affects my current issue (running when no source code was changed), but I am starting to think that the last bullet should be moved to the top. If the rules evaluate in order, I would want to rule out the branch commits while an MR is open, first.
Edward Petersen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.