I have a jenkins instance (which actually runs inside docker) for my Continous Integration.
The jenkins server builds docker images on an external docker host, tests them and then pushes them to tagged with my-app:tested
.
Now, when I build a release, I want to re-tag the docker image from tested to vX.X
. I do not want rebuild the image with a new tag, I want to re-tag the existing image.
How can this be done with jenkins? I am looking through the jenkins plugins and cannot find any with this capability.
As you do not link to any of the plugins you use I cannot easily say if they might be able to re-tag an existing image, it is however possible via a shell based job.
If you use a shell (bash or something similar) script in Jenkins you can easily do this with a standard docker command for tagging existing images. If your my-app:test image is already cached locally for your jenkins build job you can run:
If my-app:tested is cached locally for the jenkins job you can omit the
docker pull
command. See the docker tag documentation for more information. If this shell commands-based workflow does not fit into your plugins-based build workflow I'm not sure how you would do it.I do not personally use Jenkins or Jenkins plugins for building docker images, so I am not familiar with how plugins for building Docker images work in Jenkins. Someone else might be able to help you with a plugin based build job.
As shown in this blog post you can add two tags with the push command like so:
PS Mind you Jenkins folks if you're reading this a 3rd party blog post does NOT count as documentation. This could have been resolved MUCH quicker had this been properly documented.