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

好久不见. 提交于 2019-12-03 05:59:04

问题


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).


回答1:


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.




回答2:


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




回答3:


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



回答4:


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).



来源:https://stackoverflow.com/questions/29532101/git-flow-how-to-configure-a-one-click-release-process-in-jenkins

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