wawawa
wawawa

Reputation: 3355

How to add build number (from Jenkins) to jar file?

My application is build by Jenkins and Maven, I want to add the build number to jar file (this includes adding to the filename of the jar and also add the build number in the jar), potentially create a file that includes the version+build number in the jar, and I can also extract this info for other use, can someone help?

Upvotes: 0

Views: 2633

Answers (1)

yorammi
yorammi

Reputation: 6458

Use should pass the build-number to the maven build so it will be set as part of the artifact version.

I recommend to use the version:set Maven plugin (see: https://www.mojohaus.org/versions-maven-plugin/set-mojo.html) in order to set the version name.

If you want to know what the current version of the project, use the following command, and then use the result combined with the build-number for setting the new version: mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version

Upvotes: 1

Related Questions