Makla
Makla

Reputation: 10459

GitLab do not run CI/CD pipeline when creating new merge request

My GitLab CI/CD is run when I:

I would like to skip first pipeline (on creating merge request), because I would like to optimize (fasten) my CI/CD.
On creating merge request new branch is created from master which already build successfully. There is no point of running the pipeline again.

Can I do that? I already check documentation for when but no idea how to solve this.

Upvotes: 2

Views: 1761

Answers (2)

rredondo
rredondo

Reputation: 951

In your gitlab-ci.yml file try setting the following workflow:

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

This will check if the pipeline was triggered by a merge request and will prevent it from running. For all other cases, it allows the pipeline to run.

Upvotes: 1

Thomas Löffler
Thomas Löffler

Reputation: 6174

I often use the option Create branch instead of Create merge request. This can only be done in the issue view. Then the first pipeline in this branch is running after the first push into the branch. With a push in the branch you can create a merge request.

Create branch in issue view

Upvotes: -2

Related Questions