We are using the standard git flow branching model (develop, master, release-, hotfix-, etc).
As part of our workflow, we would like to set up a "one-click" release via jenkins.
I was looking at the jgitflow-maven-plugin. Can I set up this plugin to do a one-click release from jenkins? If so, what are the configuration options?
In particular, can I do something like this?
Jenkins Job
Maven goals: release-start release-finish -Dsomething -Delse
And is there a way tell it to automatically build from the latest -SNAPSHOT version, e.g. if the version is 1.2.3-SNAPSHOT
it would build release-1.2.3
.
Otherwise, is there a maven plugin that builds releases according the git flow branching model (i.e. build from develop
and create a new release branch named release-x.y.z
).
Although this answer is one year old I'd like point out that meanwhile the jgitflow (v1.0-m5.1
) works with maven batch mode.
So to release an artifact with just one command you can execute:
mvn --batch-mode jgitflow:release-start jgitflow:release-finish
You don't need to set developmentVersion
and releaseVersion
.
JGitFlow will use the current version minus the -SNAPSHOT
part as release version. Then it increments the least significant digit and adds -SNAPSHOT
again for the next development version.
Example 1.0.0-SNAPSHOT
--> Release: 1.0.0
, next Development version: 1.0.1-SNAPSHOT
In order to configure a single click Jenkins release job you need to configure some things regarding Git.
Under Source Code Management > Git > Additional Behaviors
select
Wipe out repository & force git clone
: just to make sure the workspace is cleanCheckout to specific local branch
: your develop
branch.Finally, the release happens locally on your Jenkins server, so you want to push back the changes to your Git remote server.
To accomplish this, the easiest way is to add a Post-build action
which executes the following bash command (the branch names may vary, I've used the JGitFlow default values):
git push origin develop master --tags
Note If Jenkins is running on Windows you either have to execute a Batch script containing the same command (sometimes this doesn't work due to SSH issues with Windows) or configure the Git Publisher
Post-build action
accordingly.
You can simply use the jenkins plugin M2 Release Plugin with the release goals an options
-B -DautoVersionSubmodules=true jgitflow:release-start jgitflow:release-finish
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