rules:
- if: '$CI_PIPELINE_SOURCE == "trigger"'
when: never
The way I understand it (which is also what I want it to do), is that it should prevent the job from being added to the pipeline when the contents of variable $CI_PIPELINE_SOURCE equals trigger.
This is not the case, and the job in question is always removed from the pipeline.
What am I doing wrong ?
If no if statements are true, do not add the job to the pipeline.
When no rules are specified, jobs behave with a when: on_success rule applied. By specifying your own rules, you need to provide conditions of when it should run.
Thanks, it worked.
But also generated a duplicate pipeline so I had to combine the rules tag with a workflow tag that specifies when a pipeline should run.
IMO a job should run if no rules match, and adding job rules should not force a user to add workflow rules. It is totally counter intuitive and it adds much overhead to something that should be trivial.