I have a web application where we deploy to production whenever a feature is ready, sometimes that can be a couple of times a day, sometimes it can be a couple of weeks between releases.
Currently, we don't increment our version numbers for our project, and everything has been sitting at version 0.0.1-SNAPSHOT
for well over a year. I am wondering what is the Maven way for doing continuous delivery for a web apps. It seems overkill to bump up the version number on every commit, and never bumping the version number like we are doing now, also seems wrong.
What is the recommend best practice for this type of Maven usage?
The problem is actually a two-fold one:
pom.xml
file (and there can be many).The main benefit of Continuous Integration is the ability to flag errors as they are introduced into a system instead of waiting multiple days for test failures and critical errors to be identified during the QA cycle.
A maven is a build tool designed to manage dependencies and the software lifecycle. It is also designed to work with plugins that allow users to add other tasks to the standard compile, test, package, install, deploy tasks. Jenkins is designed for the purpose of implementing Continuous Integration (CI).
Much of the project management and build related tasks are maintained by Maven plugins. Developers can build any given Maven project without the need to understand how the individual plugins work. We will discuss Maven Plugins in detail in the later chapters.
I recommend the following presentation that discusses the practical realities of doing continuous delivery with Maven:
The key takeaway is each build is a potential release, so don't use snapshots.
This is my summary based on the video linked by Mark O'Connor's answer.
1.0-SNAPSHOT
are turned into real versions such as 1.0.buildNumber
where the buildNumber
is the Jenkins job number. Algorithm steps:
1.0-SNAPSHOT
1.0.JENKINS-JOB-NUMBER
so the snapshot version is turned into a real version 1.0.124
1.0-SNAPSHOT
to 1.0.JENKINS-JOB-NUMBER
mvn install
mvn install
is a success then Jenkins will commit the branch 1.0.JENKINS-JOB-NUMBER
and a real non-snapshot version is created with a proper tag in git to reproduce later. If the mvn install
fails then Jenkins will just delete the newly created branch and fail the build.I highly recommend the video linked from Mark's answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With