2

I have this jenkinsfile that I run on jenkins

node("MacMiniSlave") {
  try{
  withEnv(["PATH=${env.HOME}/.rbenv/versions/2.3.1/bin:${env.PATH}","http_proxy=http://proxy.singaporepower.com.sg","https_proxy=http://proxy.singaporepower.com.sg","LANG=en_US.UTF-8","LANGUAGE=en_US.UTF-8"]){
      sh "env"
      echo "My branch is: ${env.BRANCH_NAME}"
    }
    currentBuild.result='SUCCESS'
  }catch(Exception e){
    currentBuild.result="FAILURE"
    throw e
  }finally{
    step([$class: 'GitHubCommitNotifier', resultOnFailure:'FAILURE'])
  }
}

but the output from this is My branch is: null. Why is it so?

Moses Liao GZ
  • 1,556
  • 5
  • 20
  • 45
  • There's really a lot of important information that you haven't mentioned here. What makes you think it should be anything but null? – David M. Karr Feb 11 '17 at 23:23
  • The environment of the Jenkins script may not be the same as the environment that the shell commands get executed with. You can [print out an environment dump](http://stackoverflow.com/questions/36836806/retrieve-all-properties-of-env-in-jenkinsfile) to see which variables are available. – Ben S May 02 '17 at 12:02
  • Having the same issue with Jenkins 2.46.3 :-( – Marco Faustinelli Jul 20 '17 at 12:59

0 Answers0