I've deal with the same problem. The variable is available as BRANCH_TEST (and not env.BRANCH_TEST). If you need env variables, you must use WithEnv keyword. regards, --
Ludovic SMADJA R&D engineer - build process and development JALIOS SA http://www.jalios.com Le mardi 24 mai 2016 à 15:34 -0700, Matt Evans a écrit : > I have tried many ways to bring variable in scope to a function, can > you please clarify how the following code should be written to bring > the variable "BRANCH_TEST" in scope? > > def BRANCH_TEST = "master" > > node { > deploy() > } > > def deploy(){ > echo env.BRANCH_TEST > } > > Console Output: > [Pipeline] echo > null > > > > > I think I could just echo "$env.BUILD_NUMBER" for those who > > > > are wondering. I didn't test doing so though I am sure it would > > > > work. > > Either: > > > > echo env.BUILD_NUMBER > > > > or > > > > echo "${env.BUILD_NUMBER}" > > > > (Not sure whether Groovy gives higher precedence to `$` or `.` so > > play it safe and use braces if inside a GString.) > > > > BTW as of the 1.5 release, the live documentation (i.e., Snippet > > Generator) for environment variable handling has been consolidated > > into the help for the new withEnv step, which seemed the most > > appropriate place for it. > > > -- > You received this message because you are subscribed to the Google > Groups "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, > send an email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/jenkinsci-users/fa738334-df6c-48a6-987f- > cf4299200cc8%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1464183197.23944.7.camel%40jalios.com. For more options, visit https://groups.google.com/d/optout.
