Reputation: 5029
I am creating CI pipeline with Jenkins. Need to tag the docker images with the Maven version of the project, e.g. 0.0.1-SNAPSHOT
.
Although, maven version is exposed as POM_VERSION
based on this Jenkins issue, it seems to apply only to the "Maven project". I tried to use the variable in Pipeline's Jenkins file as ${POM_VERSION}
and it did not recognize the property.
What is the best way to get the version number? Parse the pom.xml and grep the version with a bash script and call it inside Jenkinsfile
?
Upvotes: 2
Views: 2333
Reputation: 2486
You can tag docker image with project version using Spotify docker maven plugin as follows :
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<imageName>${image.suffix}/${project.artifactId}:${project.version}</imageName>
Upvotes: 2