Gitlab-ci.yml: "rules:changes" clauses ignored upon pushing a tag (CI/CD)
Summary
When defining a Gitlab-ci.yml like so:
test_changes_rule:
script: echo on change
rules:
- changes:
- foo.txt
The rules are ignored when pushing a tag -> the pipeline is triggered even if it has nothing to do with the foo.txt
file
Steps to reproduce
- Create new project
- Add a file named foo.txt
- Create the .gitlab-ci.yml file containing:
test_changes_rule:
script: echo on change
rules:
- changes:
- foo.txt
- Add another file called
bar.txt
(this will not trigger a pipeline - as expected). - Modify
foo.txt
(this will trigger the pipeline - as expected). - Modify
bar.txt
(this will not trigger the pipeline - as expected). - From the UI create a new "tag" (this will trigger the pipeline - not expect).
The version of Gitlab I've seen this on are Gitlab 12.4.2
and 12.5.4
What is the current bug behavior?
A tag push ignores the rules:changes section of the job in the gitlab-ci.yml
file and triggers a pipeline (see gitlab-ci.yml
file above)
What is the expected correct behavior?
Pushing a tag should not trigger a pipeline if the rules specifically say that a pipeline should be triggered only when changing specific files (which are not changed in this specific case)