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

前端 未结 4 1158
栀梦
栀梦 2021-02-01 09:21

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\" r

相关标签:
4条回答
  • 2021-02-01 09:44

    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.

    0 讨论(0)
  • 2021-02-01 09:45

    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

    0 讨论(0)
  • 2021-02-01 09:47

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

    0 讨论(0)
  • 2021-02-01 09:49

    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
    
    0 讨论(0)
提交回复
热议问题