Given a jenkins 2.1 build pipeline, jenkins injects a env
variable into the node{}
. For example, BRANCH_NAME
can be accessed with
node {
echo ${env.BRANCH_NAME}
...
env
properties within the jenkins pipeline...considering that I do not know all properties ahead of time.
I'm looking for code like
node {
for(e in env){
echo e + " is " + ${e}
}
...
which would echo something like
BRANCH_NAME is myBranch2
CHANGE_ID is 44
...
According to Jenkins documentation for declarative pipeline:
sh 'printenv'
For Jenkins scripted pipeline:
echo sh(script: 'env|sort', returnStdout: true)
The above also sorts your env vars for convenience.