sebastiandaschner blog

Continuous Delivery friendly Maven versions

#maven #continuousdelivery saturday, december 09, 2017

A Continuous Delivery pipeline requires predictable software and dependency versions. Snapshot versions, which are common in Maven software projects, contradict the motivation behind Continuous Delivery.

In order to update snapshot versions to release versions developers usually edit the pom.xml file by hand or via a plugin such as the maven-release-plugin. However, Maven also offers the possibility to define version numbers as properties, which fits the Continuous Delivery world better.

It is possible to use placeholders such as ${revision} as artifact versions, as described here. We can therefore define a version that consists of a semantic version including the build number of the CI server as metadata:

<project xmlns=""



        <!-- will be overridden in CD pipeline -->

In order to issue a local build which won’t be published on any environment, we invoke mvn clean package as usual. This results in the artifact version 1.0.0+local.

The Continuous Integration server will invoke the Maven build similar to: mvn clean package -DbuildNumber=b${buildNumber} — with the build number taken from the current pipeline build. This results in artifact versions 1.0.0+b123, 1.0.0+b124, and so on. The same property is set in order to mvn deploy the artifact to a repository.

This approach comes in handy to both specify predictable versions and fallback versions for local builds. It’s important to note that the semantic version 1.0.0 should only changed by developers, since it reflects the nature and compatibility of API-changes.


Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: