I haven't seen anywhere guidance on how to access environment variables 
such as BUILD_NUMBER from a flow.groovy workflow definition script? I tried 
Timur's 
solution 
<https://groups.google.com/forum/#!searchin/jenkinsci-users/workflow$20environment$20variable/jenkinsci-users/OvEqfy6RJBI/xpsFHTc0OsUJ>
 by 
passing in $BUILD_NUMBER as the build parameter but then it was interpreted 
as a string instead of pulling the build number from the shell environment.

My goal is to tag a Docker image with the build number for reproducibility and 
auditability reasons. I am using a workflow definition to store my JAR binary 
into a Docker container which then gets deployed to a Docker Host for testing 
and production use.


Is there currently any way pull the build number from the environment into 
a workflow definition script?

I tried running a shell command to echo the $BUILD_NUMBER to see if I might 
be able to echo it and then store it in a variable in my Groovy script. 
That didn't work and it gave me the a MissingPropertyException:

groovy.lang.MissingPropertyException: No such property: BUILD_NUMBER for class: 
groovy.lang.Binding
        at groovy.lang.Binding.getVariable(Binding.java:62)
        at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:139)



Maybe there is something I am limited to by the fact I am in a Groovy sandbox.


This would be a nice feature if we could get it working.



-- 
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/98f2f32e-cc7b-40e6-a4f6-c55d055a7608%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to