Search code examples
mavenjenkinssemantic-versioning

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.


Solution

  • 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.