I need the tag value of my last pushed git commit in my gitlab-ci.yml when building. In the build process I build a docker image and after the build I want to push this images tagged with the same tag as my git commit. So far my understanding is that the environment variable $CI_COMMIT_TAG
should do the work. Nevertheless when I echo out $CI_COMMIT_TAG
in my gitlab-ci.yml is it just empty.
Here is my gitlab-ci.yml:
stages:
- build
build-dev:
stage: build
environment: development
only:
- master
tags:
- ms-doorman
script:
- echo $CI_COMMIT_TAG
Here the git commands to start the job.
$ git commit -am "test git tags"
$ git tag test-tag
$ git push --tags origin master