Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Project Version from Maven POM in Jenkins

Tags:

maven

jenkins

Is there any way a Jenkins build can be aware of the Maven version number of a project after processing the POM?

I've got some projects where versioning is controlled by Maven, and in a post-build job we'd like to create a Debian package and call some shell scripts. What I need is for the version number that Maven used to be available as a Jenkins environment variable so I can pass it to post-build actions.

To be clear, I'm not needing to know how to get Jenkins to pass a version number to Maven; instead I want Maven to pass a version number to Jenkins!

like image 432
EngineerBetter_DJ Avatar asked Mar 27 '12 16:03

EngineerBetter_DJ


People also ask

What is version in maven POM xml?

version. It is the sub element of project. It specifies the version of the artifact under given group. File: pom.xml.

What is version in Pom?

The version number of the artifact defined in the POM file is the same as the version number of the released product, for example 12.1. 2.0. 0, expressed using five digits, as described in the following: In x.x.x-y-z : x.x.x is the release version number, for example 12.1.


1 Answers

You can use the ${POM_VERSION} variable, which was introduced with https://issues.jenkins-ci.org/browse/JENKINS-18272

like image 193
Nils Breunese Avatar answered Sep 28 '22 06:09

Nils Breunese