Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In gitlab, how to set "pipelines must succeed" only for specific branches but not others for a merge request to merge?

In the merge checks settings, I have enabled the "pipelines must succeed" option:

enter image description here

But the branches without any jobs are stuck at merge by saying "waiting for pipelines status" and you can't merge without a successful pipeline.

Can I enable the "pipelines must succeed" option only for some specific branches like master/production?

like image 842
shaik reyan Avatar asked Nov 22 '25 19:11

shaik reyan


1 Answers

As a workaround, you can trigger a merge request pipeline from the branches that don't currently have any jobs. The pipeline can have a single job that always passes. A merge request pipeline will only be created after a MR is created, not before.

A simple job like this should work:

print-info:
  stage: setup
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
  script:
    - 'echo "Job start: $CI_JOB_STARTED_AT"'
    - 'echo "Branch: $CI_COMMIT_BRANCH"'
    - 'echo "Commit Author: $CI_COMMIT_AUTHOR"'

Note: I'm not sure what your current pipeline looks like, so you may have to change the rules section to suit your needs.

like image 179
DV82XL Avatar answered Nov 26 '25 15:11

DV82XL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!