I am creating a sample jenkins pipeline, here is the code.
pipeline {
agent any
stages {
stage(\'test\') {
steps {
It requires a bit of rearranging, but when
does a good job to replace conditionals above. Here's the example from above written using the declarative syntax. Note that test3
stage is now two different stages. One that runs on the master branch and one that runs on anything else.
stage ('Test 3: Master') {
when { branch 'master' }
steps {
echo 'I only execute on the master branch.'
}
}
stage ('Test 3: Dev') {
when { not { branch 'master' } }
steps {
echo 'I execute on non-master branches.'
}
}