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
Another, more concise way:
node { echo sh(returnStdout: true, script: 'env') // ... }
cf. https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#code-sh-code-shell-script