I am stuck at how to properly use nested conditions as proposed in the Jenkins syntax.
https://jenkins.io/doc/book/pipeline/syntax/#when
This is my current stage:
stage('Build'){
when{
anyOf{
allOf{
expression{env.BRANCH_NAME != 'master'}
expression{env.AUTO_BUILD == true && env.BUILD_OPT == snapshot && env.BRANCH_NAME !=~ /feature.+/}
}
expression{env.AUTO_BUILD == false}
}
}
steps{
echo env.AUTO_BUILD
echo env.BUILD_OPT
echo env.BRANCH_NAME
}
From my point of understanding is, if I set env.AUTO_BUILD = false
, then this stage should be executed, since it is enclosed in an anyOf
OR it would execute if my branch was e.g. develop
and AUTO_BUILD = true, BUILD_OPT = snapshot
.
However, this was not the case when I set AUTO_BUILD = false
. The stage was not executed. Am I missing something?