Get git branch name in Jenkins Pipeline/Jenkinsfile

前端 未结 7 1343
借酒劲吻你
借酒劲吻你 2020-12-13 08:06

I\'ve create a jenkins pipeline and it is pulling the pipeline script from scm.
I set the branch specifier to \'all\', so it builds on any change to any bra

7条回答
  •  被撕碎了的回忆
    2020-12-13 08:54

    A colleague told me to use scm.branches[0].name and it worked. I wrapped it to a function in my Jenkinsfile:

    def getGitBranchName() {
        return scm.branches[0].name
    }
    

提交回复
热议问题