Add $CI_ISSUE_NUMBER variable to the set of CI Environment variables

Description

In many scenarios a CI Job could needs the information of which Issue number is related with the current Job execution. This could be very useful for example in artifact of environment naming especially for review apps, and could simplify the identification of them by not-technical people (please see a concrete scenario here: https://gitlab.com/gitlab-org/gitlab-ce/issues/27921#note_37030884).

So, the main goal of this proposal is to give to the CI users a powerful variable that can simplify the naming of artifacts and environments.

Proposal

Gitlab runner can access to the current branch name (or tag) using the $CI_COMMIT_REF_NAME variable. Gitlab expose also the $CI_COMMIT_REF_SLUG that is a "regexped" version of the branch name, to be suitable for DNS name etc. The feature branches in Gitlab follow the name convention ISSUE_NUMBER-ISSUE_DESCRIPTION.

The proposal is to create another CI variable that ($CI_ISSUE_NUMBER) that knowing the naming convention of gitlab feature branches, expose the ISSUE_NUMBER. (If the branch or tag name don't follow that convention, we can simple leave empty the value of this variable).

I think a simply regexp on $CI_COMMIT_REF_NAME variable could implement this proposal.

Links / references

List of current CI environment variables: https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables

Documentation blurb

Overview

What is it? Why should someone use this feature? What is the underlying (business) problem? How do you use this feature?

Use cases

  • Naming the environments or the url of environments with the related issue number.
  • Naming the artifacts with the related issue number.

Feature checklist

Make sure these are completed before closing the issue, with a link to the relevant commit.

  • Feature assurance
  • Documentation
  • Added to features.yml
Assignee Loading
Time tracking Loading