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
Cross-platform way of listing all environment variables:
if (isUnix()) { sh env } else { bat set }