Interview Prep/Jenkins/Declarative pipeline syntax

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 * * *' : '').

All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax