Add CI variable for MR destination branch name

Description

In GitLab CI builds only the "source" branch name of a merge request is available (CI_COMMIT_REF_NAME).

The "destination" branch name of a merge request could be used alter the behavior of CI builds.

Proposal

Add the following environment variables:

  • CI_MERGE_REQUEST_BRANCH_NAME
    • MR: Name of destination branch
    • No MR: Fallback to CI_COMMIT_REF_NAME
  • CI_MERGE_REQUEST_BRANCH_SLUG (same behavior as CI_COMMIT_REF_SLUG)

Links / references

  • None

Documentation blurb

Variable GitLab Runner Description
CI_MERGE_REQUEST_BRANCH_NAME ? ? The destination branch name of the merge request for which project is built. Falls back to CI_COMMIT_REF_NAME when no merge request is built.
CI_MERGE_REQUEST_BRANCH_SLUG ? ? $CI_MERGE_REQUEST_BRANCH_NAME lowercased, shortened to 63 bytes, and with everything except 0-9 and a-z replaced with -. Use in URLs and domain names.