I would like to print all available properties (and their values) in env
object inside Jenkinsfile.
When I do
print env
I get:
org.jenkinsci.plugins.workflow.cps.EnvActionImpl@112cebc2
So it looks like toString
is not implemented there, how can I access properties that are in this object if I don't know their names?
In "Manage Jenkins" -> "Configure System" -> "Global Properties" -> "Environment Variables" I added "ALL_NODES_ENVVAR".
Make sure you're not running the pipeline script in sandboxed mode and you should be able to use:
env.getEnvironment()
Note, if you're running in sandbox mode in a pipeline, you should approve the method at the script approval page: http://jenkins-host/scriptApproval/
To retrieve all env properties using a Jenkinsfile written in either declarative or scripted DSL you can use:
sh 'env'
or
sh 'printenv'
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