I am trying to tag my docker image`. I am using Jenkins to do that for me by declaring a string parameter.
In the docker-compose.yml file I have my image like so:
image: api:"${version}"
I get an error saying the tag is incorrect.
In my Jenkins pipeline I have a string parameter named version with default LATEST. However, I want to be able to enter v1 or v2 which will be used as an image tag.
I am doing it using blue-green deployment.
You can set the
VERSIONin the environment for the build usingwithEnvin your pipeline, for example:The version number set in the Jenkins build environment is used by the
docker buildcommand.Note: the
javaapplication that I'm building withmaven(e.g.mvn clean install) is purely for example purposes, the code is available https://stackoverflow.com/a/54450290/1423507. Also, the colorized output in Jenkins console requires the AnsiColor Plugin as explained https://stackoverflow.com/a/53227633/1423507. Finally, not usingdocker-composein this example, there is no difference for setting the version in the environment.