Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tag Docker images with a Git tag in Jenkins?

Hopefully I'm just missing something simple, but I cannot figure out how to tag a Docker image with a Git tag in a Jenkins job.

I have been using the Docker Build and Publish plugin for building my images, but it's tag input only seems to accept token macros for input. The Git plugin doesn't export a tag macro and I haven't been able to find an alternative plugin that does. I had tried exporting the results of git-describe with the Envinject plugin into the environment but the Docker plugin doesn't seem to be able to read environment variables, even with the ${ENV,var=VARIABLE} token macro.

I can achieve this by scripting the whole process, but I was hoping to use the Docker plugin for registry credentials management.

like image 629
catbot Avatar asked Jun 08 '15 20:06

catbot


1 Answers

After taking another look at the problem with a clearer head, I found a simple solution to this problem in scripting the creation a temporary properties file with my git tag and using Envinject's "Inject environment variables" build step to read that file.

My final configuration looked somewhat like this: enter image description here

like image 103
catbot Avatar answered Oct 16 '22 19:10

catbot