-
Improvement
-
Resolution: Fixed
-
Minor
-
None
jenkins declarative pipeline has a nice condition to check for branch names:
stage('build Snapshot') { when { not { branch 'master' } } steps { sh 'mvn clean install -Dmaven.test.failure.ignore' } }
unfortunate, it only checks for the branch name in `env.BRANCH`. Sure, I can use something like this:
when { expression { return env.GIT_BRANCH == "master" } }
but that's not as nice as the former...
The other solution for this would be, the pipeline-model-definition-plugin would check for multiple variables (BRANCH_NAME, BRANCH, GIT_BRANCH) and maybe throw an error in case they define different values (except for null).
This does not sound like a big issue, but for sure it will make a lot of things easier to understand, e.g. why would the condition behave different in a multibranch job then in a normal job?
please also see JENKINS-50622
- relates to
-
JENKINS-50622 when condition not correctly discovering branch
- Closed
- links to