0

i am writing a groovy based Jenkins pipeline , like this

    stage("checking if the branch exist in github for a repo"){
      container('golang'){            
        def checkoutPath = new utils().getCheckoutPath() 
        println checkoutPath
        dir(checkoutPath) {
         checkout([
          $class: 'GitSCM', 
          branches: [[name: 'RDO-3884']], 
              userRemoteConfigs: [[ credentialsId: 'mak', url: 'https://github.com/umLLC/service.git' ]]
         ])

          def branch = "${env.BRANCH_NAME}"
          println    env
          println   "tested-${branch}"

but i am unable to get env variables which jenkins set. every thing works fine except for "${env.BRANCH_NAME}" its always coming as null i even tried it like def branch = env.BRANCH_NAME still same result.

But "${env.JOB_NAME}" works somehow!

  • i did a sh "printenv | sort" and even in that the variable is not there,,, is there a way to activate it. – Mohammed Ali Jul 15 '19 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.