I have a variable named $DEPLOY_STAGE for each job, and it's default value is false. I want to create a rule, where if either the variable is set to true or there was a change in the directory corresponding with the job, then the job is added to the pipeline. I used the following rule on each job:
rules:
- changes:
- "job/**/*"
when: on_success
- if: '$DEPLOY_STAGE == "true"'
when: on_success
The changes part works fine, but when I manually run the pipeline and set a single variable to true, all jobs are added to the pipeline. What could be the cause of this problem?
Just to put it out there, if there is no push on a job, changes automatically evaluate to true not false.
Be careful with this one. I triggered a build storm by manually triggering (clicking run pipeline in the GUI) our top level job to see what would happen.
Reference: https://docs.gitlab.com/ee/ci/yaml/#ruleschanges
Specifically:
You should use rules: changes only with branch pipelines or merge request pipelines. You can use rules: changes with other pipeline types, but rules: changes always evaluates to true for new branch pipelines or when there is no Git push event. Pipelines like tag pipelines, scheduled pipelines, and manual pipelines, all do not have a Git push event associated with them. In these cases, use rules: changes: compare_to to specify the branch to compare against.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With