How to receive local Git branch name with Jenkins Git plugin?

前端 未结 12 747
闹比i
闹比i 2020-12-12 17:52

I am using Branch Specifier option of Jenkins Git plugin (v2.0) to run build on specific branch, e.g. 1.4.

${GIT_BRANCH} in this case conta

12条回答
  •  攒了一身酷
    2020-12-12 18:41

    As of March 2016 (Git Plugin v2.4.3) this is now supported natively. Simply put ** as the value for Check out to specific local branch in the Git Plugin, instead of any macro/variable.

    The description for the field details the new behavior:

    If selected, and its value is an empty string or "**", then the branch name is computed from the remote branch without the origin. In that case, a remote branch origin/master will be checked out to a local branch named master, and a remote branch origin/develop/new-feature will be checked out to a local branch named develop/newfeature.

    This was introduced by @roostergx & @NickVolynkin mentioned when it was released. I'm just documenting here to hopefully help folks in the future.

提交回复
热议问题