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

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

    I managed to do that with a couple steps:

    1. Add Execute shell pre step with these:

      git_branch_local=$(echo $GIT_BRANCH | sed -e "s|origin/||g") echo GIT_BRANCH_LOCAL=$git_branch_local > build.properties

    2. Add an Inject environment variables pre step for build.properties file

    then you should have a GIT_BRANCH_LOCAL environment variable that doesn't have origin/

提交回复
热议问题