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
VERSION
in the environment for the build usingwithEnv
in your pipeline, for example:The version number set in the Jenkins build environment is used by the
docker build
command.Note: the
java
application 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-compose
in this example, there is no difference for setting the version in the environment.