Jenkins pipeline branch name returns null

后端 未结 7 840
滥情空心
滥情空心 2021-01-03 22:25

I\'m trying to get the name of my branch for a jenkins groovy script. I cannot get the current branch name. I try the following:

stage(\'Check out code\')
ch         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-03 22:57

    I had this same issue, but I resolved it by changing

    println "${env.BRANCH_NAME}"
    

    to

    println "${BRANCH_NAME}"
    

    Note my plugin is also checking out in detached mode:

    git checkout -f e10a170e17fb5f9282f903a7b3cd17bd2e181dee
    

提交回复
热议问题