在 gitlab 中,如何只为特定分支设置 "pipelines must succeed" 而不是其他分支以合并请求合并?
In gitlab, how to set "pipelines must succeed" only for specific branches but not others for a merge request to merge?
在合并检查设置中,我启用了“管道必须成功”选项:
但是没有任何作业的分支会因为“等待管道状态”而卡在合并中,如果没有成功的管道就无法合并。
我能否只为某些特定分支启用“管道必须成功”选项,例如 master/production?
我认为这是不可能的。
You should ensure that there is always a pipeline and that it’s successful.
作为解决方法,您可以从当前没有任何工作的分支触发 merge request pipeline。管道可以有一个始终通过的作业。合并请求管道只会在创建 MR 之后创建,而不是之前。
像这样的简单工作应该可行:
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.
在合并检查设置中,我启用了“管道必须成功”选项:
但是没有任何作业的分支会因为“等待管道状态”而卡在合并中,如果没有成功的管道就无法合并。
我能否只为某些特定分支启用“管道必须成功”选项,例如 master/production?
我认为这是不可能的。
You should ensure that there is always a pipeline and that it’s successful.
作为解决方法,您可以从当前没有任何工作的分支触发 merge request pipeline。管道可以有一个始终通过的作业。合并请求管道只会在创建 MR 之后创建,而不是之前。
像这样的简单工作应该可行:
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.