ghprb-plugin icon indicating copy to clipboard operation
ghprb-plugin copied to clipboard

Jenkinsfile env.BRANCHNAME returns null value

Open ssubramanian123 opened this issue 8 years ago • 4 comments

Hi,

I am trying to pass the branch name value from my Jenkins file to my groovy script. I tried to get the values as below but always getting empty value passed to the script. Is there any step i m missing? If I hardcode branchname then it works fine.

`node('master') { checkout scm functions = load 'pipeline-library/myfunctions.groovy'

    //def BRANCH_NAME=${env.BRANCH_NAME}
   //above one not working, passing null value

    //def BRANCH_NAME = sh(script: 'git rev-parse --abbrev-ref HEAD', returnStdout: true).trim()
   //above line not working, passing null value

   //def BRANCH_NAME ="develop"
   //working - passing value as "develop"

   myfunctions.MyGroovyScript("${BRANCH_NAME}")

} `

ssubramanian123 avatar May 15 '17 21:05 ssubramanian123

bump

dbwest avatar Dec 22 '17 18:12 dbwest

+1

env.BRANCH_NAME not working on pipeline but it does on multibranch pipeline

benzsuankularb avatar Dec 31 '17 12:12 benzsuankularb

+1

maxyermayank avatar Jul 16 '18 16:07 maxyermayank

+1

mattemoore avatar Mar 04 '19 19:03 mattemoore