The when branch conditional seems to still be broken. Similar to JENKINS-41012. In this case we are using GitHub with webhooks to trigger a build. Following the good test code in 41012 I tested with the following.
Results - I get echo expression and echo env, but branch is always skipped.
Test pipeline code stage is:
stages {
stage('test condition: expression') {
when {
expression {
return env.GIT_BRANCH == "origin/master"
}
}
steps {
sh 'echo "expression"'
}
}
stage('test when: env') {
when {
environment name: "GIT_BRANCH", value: "origin/master"
}
steps {
sh 'echo "env"'
}
}
stage('test when: branch') {
when {
branch "master"
}
steps {
sh 'echo "branch"'
}
}
}
The when branch conditional seems to still be broken. Similar to - JENKINS-41012-. In this case we are using GitHub with webhooks to trigger a build. Following the good test code in 41012 I tested with the following.
Results - I get echo expression and echo env, but branch is always skipped.
The branch conditional is checking against the more generalized BRANCH_NAME environment variable, which is only set for multibranch Pipelines. Is this on a multibranch Pipeline or just a standalone Pipeline job?
Probably environment name: "GIT_BRANCH", value: "origin/master" as you tried out above - there's no consistent env var for the branch across all SCMs except in the context of a multibranch Pipeline, so you do need check that Git-specific one.