Using git tag as docker container tag

Hi, I configured a build which steps are pull, build and push to docker hub. The problem is that I want to trigger it each push (or merge) performed over a master branch in git. Each push will use a specific tag, and I need to use that git tag number as container tag. Example: push to master -tag 0.0.8 should build an image called myImage/image:0.0.8

How could I do that?, since I could not find vcs tag as parameter in configuration.

 

0
1 comment

Hi Marcos,

 

I'm afraid the tags won't be available directly via built-in parameters. The easiest solution would be to add a step, probably at the beginning of the build, that runs a script that pulls the tag and parses its value, exporting it to a build parameter that you can use through the rest of the build. Then you can simply reference this parameter throughout the build, different steps, and if you split it in multiple dependent build, use dependency parameters.

 

More information on setting up parameters from within build steps here: https://confluence.jetbrains.com/display/TCD18/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-AddingorChangingaBuildParameter

0

Please sign in to leave a comment.