Feature: New ENV variable for exposing merge request base branch

Description

Introduce another environment variable in order to track the base branch reference when running tasks using CI.

I want to get the base reference so that in one of the CI pipeline steps I can validate that the code being committed into the repository has code coverage statistics - I already get this information from LLVM-COV but now need the second piece of the puzzle, the diff, which can be used to cross reference with the coverage report.

Proposal

  • Proposal would be to introduce another environment variable which exposes the merge request base branch reference sha.
  • CI_BASE_BRANCH_COMMIT_SHA would be acceptable as far as naming.
  • Only would be available for open merge requests.

Could also introduce these variables at the same time:

  • CI_BASE_BRANCH_COMMIT_REF_NAME
  • CI_BASE_BRANCH_COMMIT_REF_SLUG

Links / references

https://docs.gitlab.com/ce/ci/variables/#predefined-variables-environment-variables

Documentation blurb

CI_BASE_BRANCH_COMMIT_SHA - The commit revision for which the current branch is based from.

  1. Useful if you want to check where the code is going to be merged in. Especially useful if you need to perform CI steps based on the diff available. The problem is that there is no way to expose the diff of the merge request to the CI runners.
  2. Expose the base branch commit sha in the environment variables
  3. This feature would be used as per any other environment variable.
Edited Aug 20, 2020 by Jackie Porter
Assignee Loading
Time tracking Loading