Ahmet Karakaya
Ahmet Karakaya

Reputation: 10147

Gitlab Double pipeline triggering issue

When pushing a commit two pipeline jobs are triggered. But the same thing has not occurred when starting the pipeline manually.

Where I should check? What is the meaning of the arrow from the left or from the right indicating branch activities?

One thing I have to say is that there is a merge request pending, does it cause this issue?

enter image description here

Upvotes: 4

Views: 5287

Answers (2)

SPMSE
SPMSE

Reputation: 628

The thing with your solution is that it only avoids pipeline execution when you have a merge request event, but there still will be duplicate pipelines, e.g. merge-request pipelines (the detached ones) and branch pipelines (others), also when pushing a tag your setup will create a separate pipeline I think.

Following the docs you can avoid duplicate pipelines and switch between Branch- and MR-Pipelines when using the following rules-set for workflow (I added the || $CI_COMMIT_TAG) since when pushing a tag also a pipeline should be created (but maybe only a few jobs will be added into this pipeline)

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
      when: never
    - if: '$CI_COMMIT_BRANCH' || '$CI_COMMIT_TAG'

this pipeline is a merge-request pipeline, you can see this because it's detached and because of the Merge-Request Symbol and the number of the MR on the left hand side of the commit id

merge-request pipeline

The following screenshot shows a 'normal' branch-pipeline, which is denoted by the branch-name and the GitLab branch symbol on the left of your commit id

branch-pipeline

Upvotes: 5

Ahmet Karakaya
Ahmet Karakaya

Reputation: 10147

Pending merge request cause second pipeline jobs triggered. After adding the following into gitlab-ci.yml file it is resolved

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: never
    - when: always

Upvotes: 2

Related Questions