Given a jenkins build pipeline, jenkins injects a variable env
into the node{}
. Variable env
holds environment variables and values.
I want to print all env
properties within the jenkins pipeline. However, I do no not know all env
properties ahead of time.
For example, environment variable BRANCH_NAME
can be printed with code
node {
echo ${env.BRANCH_NAME}
...
But again, I don't know all variables ahead of time. I want code that handles that, something like
node {
for(e in env){
echo e + " is " + ${e}
}
...
which would echo something like
BRANCH_NAME is myBranch2
CHANGE_ID is 44
...
I used Jenkins 2.1 for this example.