Skip to content

CI Variable for docker tags similar to CI_COMMIT_REF_SLUG

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

As a Gitlab and Docker user, I would like a CI environment variable which can be used as a docker tag and that is extrapolated from the git branch/tag name.

Problem to solve

In Gitlab, we currently have CI_COMMIT_REF_NAME and CI_COMMIT_REF_SLUG which respectivly represent the branch or tag name, and the latter but lowercased, shortened to 63 bytes, and anything other that [0-9a-z] transformed into a '-'

Docker tag naming follows yet another naming scheme. A valid git tag will fail in a CI job whose docker tag is set to CI_COMMIT_REF_SLUG

I propose an additional variable CI_COMMIT_REF_DOCKER_TAG_SLUG (naming is hard :-) ) that would transform a proper git branch/tag name into a valid docker tag name.

e.g: Branch "7.3.0-24+deb8" tag would be transformed into:

  • 7-3-0-24-deb8 for CI_COMMIT_REF_SLUG
  • 7.3.0-24+deb8 for CI_COMMIT_REF_DOCKER_TAG_SLUG

Out of scope: invalid git branch names such a "7.3.0-24~slim5+deb8", transforming a git "master" branch into a docker "latest".

Target audience

Edited by 🤖 GitLab Bot 🤖