We got around this by adding functions to the environment
step, i.e.:
environment {
ENVIRONMENT_NAME = defineEnvironment()
}
...
def defineEnvironment() {
def branchName = "${env.BRANCH_NAME}"
if (branchName == "master") {
return 'staging'
}
else {
return 'test'
}
}