Skip to content

Chapter 7 of 10

Build Triggers

Start builds from source events, polling, cron schedules, and upstream results.

34 minutes 10 quick checksBy Subha Prasad
Lesson 7 of 10Course navigation

Lesson content

Read, practise, then check your understanding

Build Triggers: SCM, Webhooks, and Schedules

A trigger connects external change or time to a Jenkins build. Webhooks provide fast event-driven feedback. SCM polling checks for changes on a schedule. Cron starts work regardless of source changes, while upstream relationships chain jobs.

Core ideas

  • A webhook is usually lower latency and load than frequent SCM polling.
  • pollSCM evaluates source changes on a Jenkins schedule; it does not necessarily build at every interval.
  • cron schedules the pipeline itself. Jenkins supports H to hash start times and spread load.
  • Multibranch pipelines discover branches and pull requests and load their Jenkinsfiles.

How it works

Authenticate webhook endpoints, verify delivery logs, and avoid triggering the same build through both webhook and polling unless deduplication is intentional. Use schedules for maintenance or periodic verification, not as a substitute for reliable event delivery.

Configuration example

pipeline {
  agent any
  triggers {
    pollSCM('H/15 * * * *')
    cron('H 2 * * 1-5')
  }
  stages {
    stage('Nightly verification') {
      steps { sh './ci/full-verification.sh' }
    }
  }
}

The sample is intentionally small. In a real installation, replace hostnames, labels, credentials, retention, and commands with reviewed values from your own platform standards.

Production guidance

  • Use H rather than a fixed minute to reduce synchronized controller load.
  • Restrict expensive scheduled jobs and add timeouts so overlap cannot grow without bound.
  • Log the source event, revision, branch, and cause to make unexpected runs traceable.

The chapter quiz follows this lesson and tests both terminology and safe operating choices.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement correctly describes webhook?
Which term matches this explanation: An immediate HTTP event from source control that can start a build.
Which statement correctly describes pollSCM?
Which term matches this explanation: A trigger that periodically checks source changes without building on every poll.
Which statement correctly describes cron trigger?
Which term matches this explanation: A Jenkins schedule using cron-like fields and the H hash notation.
Which statement correctly describes upstream trigger?
Which term matches this explanation: Starting one job after a selected earlier job reaches a specified result.
Which statement correctly describes quiet period?
Which term matches this explanation: A delay used to combine closely spaced change notifications before building.

0 of 10 checks passed

Your progress is saved on this device.