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

前端 未结 12 783
闹比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:36

    While it's true, as dtabuenc says in a comment to Jan Včelák's answer, that shell syntax isn't going to work on token macros directly, if you are trying to get at the branch name in an Execute Shell build step (or similar), you can still use the same idea.

    TEMP_GIT_BRANCH=${GIT_BRANCH}
    MY_GIT_BRANCH="${TEMP_GIT_BRANCH#*/}"
    

    works fine (and that's valid POSIX, no bash required).

提交回复
热议问题