Interview Prep/Jenkins/Declarative pipeline syntax

What are the most useful `when` conditions?

IntermediateConceptDeclarative pipeline syntax
Answer
when { branch 'main' }                       // multibranch only, uses BRANCH_NAME
when { branch pattern: 'release/\\d+', comparator: 'REGEXP' }
when { changeRequest target: 'main' }        // PR builds
when { buildingTag() }  /  when { tag 'v*' }
when { changeset 'services/api/**' }
when { environment name: 'DEPLOY', value: 'true' }
when { expression { params.RUN_E2E } }
when { triggeredBy 'TimerTrigger' }
when { allOf { branch 'main'; not { changeRequest() } } }
when { anyOf { branch 'main'; branch 'hotfix/*' } }
All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax