Not sure exactly how it worked in he 1.x versions, but for pipeline, at least, you usually have to either interpolate the variable into the string of the shell script with double quotes:
sh "echo ${ARTIFACT_VERSION}" Or you have to put the in the env object so they get injected into the shell's environment: env.ARTIFACT_VERSION = ARTIFACT_VERSION sh 'echo $ARTIFACT_VERSION' On Monday, November 13, 2017 at 7:33:59 AM UTC-7, Mahesh Wabale wrote: > > Hi All , > > > Recently i have upgraded jenkins to 2.87 from 1.611 . > > But i am facing issue with groovy . I am not able to access groovy > variables in shell . Its giving empty value. > > Here is example : > > In system groovy script : > > def project = new XmlSlurper().parse(new File("$workspace/pom.xml")) > > def ARTIFACT_VERSION=project.version.toString(); > > println ARTIFACT_VERSION > ==================> It is returning correct value. > > > > But if i am pring same variable in shell > > echo $ARTIFACT_VERSION > ===================> it is not printing anything with jenkins 2.X ( but it > is working fine with jenkins 1.X) > > > Is there any specific changes require to access groovy variables in shell > ? may be syntax or some plugins upgrade ? > > > Thanks , > Mahesh > > > > -- 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 jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5612104a-399f-4247-9f41-bebbadb267a7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.