What triggers can a declarative pipeline declare?
IntermediateConceptDeclarative pipeline syntax
Answer
triggers {
cron('H 2 * * 1-5') // nightly on weekdays
pollSCM('H/15 * * * *') // polling, avoid when webhooks work
upstream(upstreamProjects: 'lib-build', threshold: hudson.model.Result.SUCCESS)
}
In multibranch jobs, pushes are handled by branch source events, so triggers is mainly used for cron. Note that triggers in a branch Jenkinsfile applies to every branch; guard with cron(env.BRANCH_NAME == 'main' ? 'H 2 * * *' : '').
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate