Issue
I would evaluate two conditions in "when" sintax of my Jenkinsfile. In particular, I need to check when params.x is true and params.y is true. Can I insert both in the same expression with the "and" operator?
Solution
From jenkins documentation:
expression
Execute the stage when the specified Groovy expression evaluates to true, for example: when { expression { return params.DEBUG_BUILD } }
Note that when returning strings from your expressions they must be converted to booleans or return null to evaluate to false.
Simply returning "0" or "false" will still evaluate to "true".
So if you insert a valid groovy statement it should work.
Alternatively you can use allOf
statement, e.g.
when {
allOf {
expression { params.x == true }
expression { params.y == true }
}
}
Answered By - ymochurad