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.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With