I am trying to use some variables like repository name, branch names, build number,... from inside the Jenkinsfile
but I am not able to find any documentation regarding this.
Is there a way to print them so I can see what's available? How?
I think it may be related to Printing out variables and values in a Groovy object
Update
this.binding.variables.each {k,v -> println "$k = $v"}
I tried to include the code above but now execution fails with
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use field groovy.lang.Binding variables
at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectField(StaticWhitelist.java:177)
in our case we used the following to get all groovy-defined variables within a jenkinsfile groovy pipeline:
groovyVars = [:] << getBinding().getVariables()
groovyVars.each {k,v -> print "$k = $v"}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With