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

前端 未结 4 1140
栀梦
栀梦 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.

提交回复
热议问题