When I push changes to gitlab to an existing merge request, this triggers inconsistent numbers of pipelines.
When I push a change to a merge request, I expect gitlab to run one pipeline to see if the changes are ok, or if the pipeline fails. I am talking about the pipeline you see from the merge request:
However, sometimes two pipelines are triggered. Also, the source of the trigger in that pipeline changes.
Here is it how it can be reproduced. You have the following .gitlab-ci.yml
file:
stages:
- stage1
- stage2
job1:
stage: stage1
script:
- echo "Running default stage1, pipeline_source=$CI_PIPELINE_SOURCE"
job2:
stage: stage2
rules:
- if: $CI_PIPELINE_SOURCE == "push"
####
script:
- echo "Running STAGE2! pipeline_source=$CI_PIPELINE_SOURCE"
In the place ### you can put the following values:
- You leave it out, you do not put anything there → 2 pipelines are started, and the one in the MR is a
push
pipeline - You add
- when: never
→ 1 pipeline is started (push
) - You add
- when: always
→ 2 pipelines are started, and the one in the MR is amerge_request_event
pipeline! - You add
when: never
orwhen: always
(insideif
rule) → 1 pipeline is started (push
).
In addition, when you change the rule line to an inequality ($CI_PIPELINE_SOURCE != "push"
) in each case you will start 2 pipelines with the merge_request_event
trigger EXCEPT if your rule is
- if: $CI_PIPELINE_SOURCE != "push"
when: never
Then you have again one single pipeline with a push
trigger.
So here are two bugs as far as I can see:
- Sometimes one pipeline is started (expected) and sometimes 2 pipelines.
- In some cases the trigger source is
push
, but for no logical reason at all it also can bemerge_request_event
.
Is that problem known? Is there a bug report for these problems?