Triggers: polling, webhooks and cron

Jenkins CI/CD Course · lesson 5 of 15 · 5 min read

How a build starts decides how much load Jenkins puts on your SCM and how fast feedback arrives.

Open this lesson in the learning hub

Key points

  • pollSCM makes the controller ask the remote for the current hash on a schedule and build only if it moved.
  • Polling every five minutes across 200 jobs is over 57000 remote checks a day for a handful of real commits.
  • A webhook inverts it: the SCM posts to /github-webhook/ and Jenkins builds only when something happened.
  • Webhooks need the SCM to reach the controller, which is why polling survives behind a strict firewall.
  • Jenkins cron takes five fields and accepts H, which hashes the job name to spread load off the exact hour.
  • A trigger does not start a build instantly: the global quiet period of 5 seconds batches rapid pushes into one run.

Example

triggers {
    // webhook is better, but this is the firewalled fallback
    pollSCM('H/5 * * * *')

    // nightly, at a minute Jenkins picks from the job name
    cron('H 2 * * 1-5')

    // build me after the shared-libs job goes green
    upstream(upstreamProjects: 'shared-libs/main',
             threshold: hudson.model.Result.SUCCESS)
}

Webhooks when the SCM can reach you, polling only when it cannot, and cron with H for anything on a clock.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Jenkins CI/CD Course course, and every lesson in it is listed on the Jenkins CI/CD Course contents page.