Given a jenkins 2.1 build pipeline, jenkins injects a env variable into the node{}. For example, BRANCH_NAME can be accessed with
env
node{}
BRANCH_NAME
You can accomplish the result using sh/bat step and readFile:
sh
bat
readFile
node { sh 'env > env.txt' readFile('env.txt').split("\r?\n").each { println it } }
Unfortunately env.getEnvironment() returns very limited map of environment variables.
env.getEnvironment()