How can I create a Docker image based on a git tag in the public Registry? How can I create a Docker image based on a git tag in the public Registry? docker docker

How can I create a Docker image based on a git tag in the public Registry?


Most simple solution from the command line is a nested git-rev command:

docker tag <image> <image>:$(git rev-parse --short HEAD)"

gives you e.g.

<image> = myImage >> myImage:67df348


You can do this in the Docker registry, under your "Automated Build" settings. By default, this makes a build called "latest" based on your "master" branch, but you can add automated builds for specific git tags as well. The picture below shows the relevant screen


I've got the same issue and I've sorted this out by using this plugin:

https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin

This is not very pretty solution but it works, so:

1) Execute shell: echo TAG=${GIT_BRANCH#*/} > docker_tag

2) Inject Environment variables Properties File Path: docker_tag

3) use ${TAG} on https://wiki.jenkins-ci.org/display/JENKINS/CloudBees+Docker+Build+and+Publish+plugin