the6threplicant
the6threplicant

Reputation: 55

Jenkins, Maven and semantic versioning: How to increment either the major or minor version

At our work we release and deploy our components via a Jenkins job. The problem with this is that it only increments the "patch" version number (major.minor.patch, e.g. 4.2.1 goes to 4.2.2). What I would like is to make the job tell maven that this is a "minor" release (4.2.1 -> 4.3.0), a "major" release (4.2.1 -> 5.0.0) or patch release (default behaviour).

The interface to Jenkins to pass parameters to maven is straightforward but are there any commands to make maven update the minor or major version without having to explicitly state what version (and development version) you need. Since it can do the patch version updating so easily I'm hoping there is command to do the same for the minor or major version.

Upvotes: 5

Views: 3766

Answers (2)

kann
kann

Reputation: 737

It may help someone lately. We use Maven Build Helper plugin as below:

Minor release:

mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0 versions:commit

Major release:

mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.nextMajorVersion}.0.0 versions:commit

Patch release:

mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} versions:commit

Upvotes: 1

benjamin.d
benjamin.d

Reputation: 2871

Using mvn and the release plugin, you could easily update the version. You can do:

mvn release:update-versions

For more options, check the documentation.

Upvotes: 1

Related Questions