Build Triggers
Triggers decide when a job runs — on a schedule, on a code push, or after another job.
Syntax
H/15 * * * * # every 15 minutes
H 2 * * 1-5 # ~2 AM, Mon-FriA build trigger tells Jenkins when to start a job automatically instead of you clicking Build Now.
Common triggers
- Poll SCM — Jenkins checks the repository on a schedule and builds only if something changed.
- Build periodically — run on a fixed schedule regardless of changes (like a cron job).
- GitHub/GitLab hook trigger — the repository notifies Jenkins the instant code is pushed (a webhook).
- Build after other projects — chain jobs so one runs when another finishes.
Cron syntax
Both polling and periodic builds use a five-field cron format: MINUTE HOUR DAY-OF-MONTH MONTH DAY-OF-WEEK.
Example
# Build periodically examples (cron):
H/15 * * * * # every 15 minutes
H 0 * * * # once a day, around midnight
H 8 * * 1-5 # weekday mornings around 8 AM
# Poll SCM uses the same syntax but only builds
# when the repository actually changed.When to use it
- A GitHub webhook triggers a Jenkins build within seconds of a developer pushing to any branch.
- A nightly integration test job uses a cron schedule to run every weekday at 2 AM when the server is idle.
- A downstream deployment job is triggered automatically after the upstream build job finishes successfully.
More examples
Cron schedule trigger
Configures a pipeline to run automatically on weekday nights using a Jenkins cron expression.
pipeline {
agent any
triggers {
cron('H 2 * * 1-5') // weekdays at ~2 AM
}
stages {
stage('Nightly Tests') {
steps { sh 'mvn verify' }
}
}
}Poll SCM for changes
Polls the Git repository every five minutes and builds only when a new commit is detected.
pipeline {
agent any
triggers {
pollSCM('H/5 * * * *') // check every 5 minutes
}
stages {
stage('Build') {
steps { sh 'make all' }
}
}
}Downstream job trigger
Triggers the deploy-to-staging job automatically when the current pipeline succeeds, passing the build number.
pipeline {
agent any
stages {
stage('Build') { steps { sh 'mvn package' } }
}
post {
success {
build job: 'deploy-to-staging',
parameters: [string(name: 'VERSION', value: env.BUILD_NUMBER)]
}
}
}
Discussion