Reputation: 4329
I am finding it difficult to restrict a stage to only run on MR and be manual
I have the following rules
rules:
- when: manual
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH'
when: never
but this stage is still running under branches, i do not want it to run on any branch, only on MR
it is literally driving me crazy. Code shows what should happen but it just does not follow it
So what am I missing?
Upvotes: 4
Views: 5172
Reputation: 3043
From the documentation:
The job is added to the pipeline:
when: on_success
(default), when: delayed
, or when: always
.when: on_success
, when: delayed
, or when: always
.The job is not added to the pipeline:
when: never
.So in order to achieve your requirements (which are add manual job only on MR, otherwise, do not add the job
) the right order should be:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: manual
- when: never
This translate to: "When the first if matches -> add job manually, in all other cases -> don't add the job".
Upvotes: 5