I’m trying to adapt my
.gitlab-ci.yml file such that the image used is chosen dynamically. I know it’s possible to use predefined variables in the
image: entry of the yml file, such as
$CI_COMMIT_TAG, but this is not flexible enough for my case.
Suppose I have a Docker registry with images containing tags that correspond 1-to-1 with the tags on the Git repository. Furthermore, I’m not tagging every single commit (and I don’t want to). I now want Gitlab-CI to use the Docker image that has a tag equal to the most recent tag in the Git commit history, i.e. the tag given by
git describe --tags --abbrev=0.
So ideally, I would specify
image: <url-to-image-on-registry>:$(git describe --tags --abbrev=0)
.gitlab-ci.yml file, but this is not supported. Is there any other way to get this behaviour?