enable merge request pipeline only on master

342 views Asked by At

I am lots of branches in my repo, now I want to add MR pipeline for the master branch, and enable the Merge checks and Pipelines must succeed optional. unfortunately the repo have so many branches that I don't want to create .gitlab-ci.yml for them one by one. but as I have enabled the options for merge check, MR to the branched are stuck because they are not passed pipeline(no pipeline is configured for the branch). So anyone can help me out?

1

There are 1 answers

2
Abid Khan On

Can you also paste an snipped of your .gitlab-ci.yml file?

Hoping you must have tried this to your stages?

  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'master'

This basically will run only for a merge request to the master branch. And this chunk should be inside the source branch .gitlab-ci.yml