How to Trigger a Jenkins Pipeline on a Cron Schedule
The triggers {} block schedules builds with cron for timed runs or pollSCM to poll source control on a timetable.
Add triggers { cron(...) } to a pipeline. Jenkins extends cron with an H (hash) symbol that spreads load by picking a stable minute per job.
Nightly cron trigger
The H in the minute field spreads builds across the hour to avoid thundering herds.
Jenkinsfile
pipeline {
agent any
triggers {
cron('H 2 * * *')
}
stages {
stage('Nightly') {
steps {
sh './nightly-checks.sh'
}
}
}
}Gotchas
- Prefer
Hover a fixed minute (H 2 * * *) so Jenkins staggers jobs and avoids load spikes. - The trigger registers only after the pipeline runs at least once to parse the Jenkinsfile.
- Use
pollSCM('H/15 * * * *')to poll for changes; for push-based builds prefer SCM webhooks.
Key takeaways
triggers { cron(...) }schedules timed builds.- Use
Hto spread load across jobs and time. - The trigger activates only after one parsing run.
Related guides
How to Schedule a Jenkins Pipeline (Cron Triggers)Schedule a Jenkins pipeline with the triggers block - cron for fixed times, H hashing to spread load, and pol…
How to Use when {} Conditions in a Jenkins PipelineUse the when {} directive in a Jenkins declarative pipeline to run a stage only when branch, environment, exp…