Expose new CI variable CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED ?
Proposal
It would be great if that in addition to CI_MERGE_REQUEST_TARGET_BRANCH_NAME
GitLab CI would also expose if the target branch in an MR is protected or not, similar to how CI_COMMIT_REF_PROTECTED
works for the commit ref. The name for such a predefined variable could be CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED
.
Such a variable will help in limiting pipelines to only run if the target branch is protected. This comes in handy when e.g. you have expensive pipelines that should only run before merging into the "important" branches, not before merging into auxiliary branches.
Note that it already is possible distinguish if the target branch is the default branch (which usually is protected) by using CI_DEFAULT_BRANCH
. This proposal would make it possible to distinguish any target branch that is protected.