Reputation: 5029
I am using maven release plugin with Jenkins for CICD. For various reasons, we don't do SNAPSHOTs as we are supposed. We set up Jenkins to run build against master branch with version like 0.1, 1.0. And we would like to up the version number of release every time we run Jenkins. These are the commands I had in Jenkinsfile:
sh "mvn -B release:clean"
sh "mvn -B release:prepare"
sh "mvn -B release:perform"
Ended up getting error You don't have a SNAPSHOT project in the reactor projects list
. No surprise there since release:prepare
always looks for a SNAPSHOT branch. Is there a way to get around it? I found this option -DignoreSnapshots
for prepare
but it did not work.
Upvotes: 5
Views: 9589
Reputation: 97399
The release plugin is intended to have a 1.0-SNAPSHOT
before running release plugin mvn -B release:prepare
where it will change the version to a release version 1.0
and afterwards it will change them to 1.1-SNAPSHOT
(so called next dev version). During release:perform
the tagged state of your build 1.0
will be checked out from version control and will be executing mvn clean deploy
.
Furthermore using the release plugin can be done via:
mvn -B release:prepare release:perform
And in cases where something is going wrong you can do mvn release:clean
(but you need to remove tags if have been created manually).
If you will have only releases that will not work...Apart from that SNAPSHOT
is not a branch it is a version thing...
You can accomplish what you like via build-helper-maven-plugin and versions-maven-plugin:
mvn build-helper:parse-version versions:set \
-DnewVersion=\${parsedVersion.majorVersion}.\
${parsedVersion.minorVersion}. \
${parsedVersion.nextIncrementalVersion} \
versions:commit
After that you should commit this changes into version control (best be done via Pipelines in Jenkins). Furthermore via scm-maven-plugin:
mvn scm-maven-plugin:commit
Upvotes: 12
Reputation: 3002
Unfortunately it's not possible with maven release plugin. You should have SNAPSHOTs for that.
But if you need just update project version you can use maven version plugin
see http://www.mojohaus.org/versions-maven-plugin/examples/set.html
Upvotes: 1