Git flow: How to configure a one-click release process in Jenkins?

≡放荡痞女 提交于 2019-12-02 21:01:10

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

dimapin

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

We ended up with starting the release via CLI on the client (because in Jenkins there is a bug starting the release).

git flow release start -DautoVersionSubmodules=true

If you want to use the batch mode you need to specify developmentVersion and releaseVersion.

Created a new job in Jenkins to build the release branch and use the M2 Release Plugin to release it finally:

-B jgitflow:release-finish

If you use some custom profiles, you have to pass them additional via arguments caused by a bug.

-Darguments=-Pprofile

We never found a way to get this to work via a plugin or maven goal in Jenkins.

Our solution ended up with a bash script that did git flow release start <version>, maven release process, git flow release finish <version> and other things (git pull on develop and master at very start, git push and slack notification at very end).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!