Skip to content

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

  1. Create new project
  2. Add a file named foo.txt
  3. Create the .gitlab-ci.yml file containing:
test_changes_rule:
  script: echo on change
  rules:
    - changes:
        - foo.txt
  1. Add another file called bar.txt (this will not trigger a pipeline - as expected).
  2. Modify foo.txt (this will trigger the pipeline - as expected).
  3. Modify bar.txt (this will not trigger the pipeline - as expected).
  4. 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)