Bird
Raised Fist0
Jenkinsdevops~10 mins

Build triggers (poll SCM, webhook, timer) in Jenkins - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Build triggers (poll SCM, webhook, timer)
Start Jenkins Job Setup
↓
Choose Build Trigger Type
↓
Poll SCM
↓
Trigger Condition Met?
Yes↓
Start Build Execution
↓
Build Done
↓
End
This flow shows how Jenkins waits for a trigger (poll SCM, webhook, or timer) to start a build, then runs the build and finishes.
Execution Sample
Jenkins
pipeline {
  triggers {
    pollSCM('H/5 * * * *')
    // or
    // githubPush()
    // or
    // cron('H 4/* 0 0 1-5')
  }
  stages {
    stage('Build') { steps { echo 'Building...' } }
  }
}
This Jenkins pipeline uses triggers: polling SCM every 5 minutes, or webhook, or timer cron to start the build.
Process Table
StepTrigger TypeTrigger ConditionCondition ResultAction Taken
1poll SCMSCM changed since last build?NoWait, no build started
2poll SCMSCM changed since last build?YesStart build
3BuildBuild runningN/ABuild executes steps
4WebhookWebhook received?NoWait, no build started
5WebhookWebhook received?YesStart build
6TimerCron time reached?NoWait, no build started
7TimerCron time reached?YesStart build
8BuildBuild runningN/ABuild executes steps
9EndBuild finishedN/AJob ends, waits for next trigger
💡 Execution stops after build finishes and waits for next trigger event.
Status Tracker
VariableStartAfter Step 2After Step 5After Step 7Final
SCM_Changedfalsetruetruetruetrue
Webhook_Receivedfalsefalsetruetruetrue
Cron_Timefalsefalsefalsetruetrue
Build_Runningfalsetruetruetruefalse
Key Moments - 3 Insights
Why does Jenkins not start a build immediately after polling SCM if no changes are detected?
Because the condition 'SCM changed since last build?' is false (see execution_table row 1), Jenkins waits and does not trigger the build.
How does Jenkins know when to start a build from a webhook?
Jenkins listens for an external webhook event; when it receives one (execution_table row 5), it triggers the build immediately.
What happens if multiple triggers are configured at the same time?
Jenkins evaluates each trigger independently; if any trigger condition is true (rows 2,5,7), it starts the build.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does Jenkins start a build due to SCM polling?
AStep 2
BStep 1
CStep 4
DStep 6
💡 Hint
Check the 'Action Taken' column for 'Start build' related to 'poll SCM' trigger.
According to the variable tracker, what is the value of Build_Running after step 7?
Afalse
Btrue
Cundefined
Dnull
💡 Hint
Look at the 'Build_Running' row under 'After Step 7' column.
If the webhook trigger never receives a signal, which steps in the execution table show Jenkins waiting?
ASteps 6 and 7
BSteps 1 and 2
CSteps 4 and 5
DSteps 8 and 9
💡 Hint
Look for 'Webhook' trigger rows with 'Wait, no build started' action.
Concept Snapshot
Jenkins Build Triggers:
- poll SCM: checks source code changes on schedule
- webhook: listens for external push events
- timer: runs builds on cron schedule
Trigger conditions start builds automatically
Multiple triggers can coexist
Build runs only when trigger condition is true
Full Transcript
This visual execution shows how Jenkins build triggers work. Jenkins can start builds by polling the source code repository for changes, by receiving webhooks from external systems, or by running on a timer schedule. Each trigger type checks its condition: if SCM has changed, if a webhook event is received, or if the scheduled time is reached. When any condition is true, Jenkins starts the build. The execution table traces these checks step-by-step, showing when builds start or wait. The variable tracker shows how key variables like SCM_Changed, Webhook_Received, Cron_Time, and Build_Running change during execution. Key moments clarify common confusions, such as why builds don't start without changes or events. The quiz tests understanding by asking about specific steps and variable states. This helps beginners see exactly how Jenkins triggers control build execution.

Practice

(1/5)
1. Which Jenkins build trigger checks the source code repository regularly for changes before starting a build?
easy
A. poll SCM
B. webhook
C. timer (cron)
D. manual trigger

Solution

  1. Step 1: Understand the purpose of poll SCM

    poll SCM trigger makes Jenkins check the source code repository at set intervals for any changes.
  2. Step 2: Compare with other triggers

    Webhook triggers build instantly on code push, timer triggers build at scheduled times, manual trigger requires user action.
  3. Final Answer:

    poll SCM -> Option A
  4. Quick Check:

    poll SCM = checks repo regularly [OK]
Hint: poll SCM means Jenkins checks repo regularly [OK]
Common Mistakes:
  • Confusing webhook with poll SCM
  • Thinking timer triggers check repo changes
  • Assuming manual trigger is automatic
2. Which of the following is the correct syntax to schedule a Jenkins build every day at midnight using cron?
easy
A. * * * * 0
B. 0 0 * * *
C. 0 12 * * *
D. 0 0 0 * *

Solution

  1. Step 1: Understand cron syntax

    Cron format is 'minute hour day month weekday'. To run at midnight daily, minute=0 and hour=0.
  2. Step 2: Match the correct expression

    0 0 * * * "0 0 * * *" means every day at 00:00 hours (midnight).
  3. Final Answer:

    0 0 * * * -> Option B
  4. Quick Check:

    Midnight daily cron = 0 0 * * * [OK]
Hint: Midnight daily cron is always '0 0 * * *' [OK]
Common Mistakes:
  • Mixing hour and minute fields
  • Using wrong day or weekday values
  • Confusing 12 PM with midnight
3. Given this Jenkins pipeline snippet, what will trigger the build?
triggers {
  pollSCM('H/15 * * * *')
}
medium
A. Build runs only if SCM changes detected every 15 minutes
B. Build runs every 15 minutes regardless of changes
C. Build runs once daily at 15 minutes past midnight
D. Build runs immediately after a webhook event

Solution

  1. Step 1: Understand pollSCM with 'H/15 * * * *'

    This means Jenkins checks the SCM every 15 minutes for changes.
  2. Step 2: Determine when build triggers

    Build triggers only if changes are detected during these checks, not every 15 minutes automatically.
  3. Final Answer:

    Build runs only if SCM changes detected every 15 minutes -> Option A
  4. Quick Check:

    pollSCM triggers on changes every 15 mins [OK]
Hint: pollSCM triggers only on changes, not just time [OK]
Common Mistakes:
  • Assuming build runs every 15 minutes regardless
  • Confusing pollSCM with timer trigger
  • Thinking webhook triggers are involved here
4. A Jenkins job with this trigger configuration does not start builds as expected:
triggers {
  pollSCM('H/5 * * * *')
}
What is the most likely cause?
medium
A. Timer trigger conflicts with pollSCM
B. The cron syntax 'H/5 * * * *' is invalid
C. Webhook is required for pollSCM to work
D. SCM polling is disabled in Jenkins global settings

Solution

  1. Step 1: Check pollSCM prerequisites

    pollSCM requires SCM polling enabled globally in Jenkins settings.
  2. Step 2: Validate other options

    Syntax 'H/5 * * * *' is valid; webhook is separate trigger; no conflict with timer here.
  3. Final Answer:

    SCM polling is disabled in Jenkins global settings -> Option D
  4. Quick Check:

    pollSCM needs global SCM polling enabled [OK]
Hint: pollSCM needs global SCM polling enabled [OK]
Common Mistakes:
  • Assuming cron syntax is wrong
  • Thinking webhook is mandatory for pollSCM
  • Believing timer conflicts cause failure
5. You want Jenkins to build your project automatically every weekday at 6 AM and also immediately when code is pushed to GitHub. Which trigger setup is best?
hard
A. Use only pollSCM with cron '0 6 * * 1-5'
B. Use webhook only without timer
C. Use timer trigger '0 6 * * 1-5' and configure GitHub webhook
D. Use pollSCM every minute

Solution

  1. Step 1: Understand requirements

    Build at 6 AM weekdays and immediately on GitHub push means two triggers needed: timer and webhook.
  2. Step 2: Evaluate options

    Use timer trigger '0 6 * * 1-5' and configure GitHub webhook combines timer for scheduled build and webhook for instant build on push, fulfilling both needs.
  3. Final Answer:

    Use timer trigger '0 6 * * 1-5' and configure GitHub webhook -> Option C
  4. Quick Check:

    Timer + webhook = scheduled + instant builds [OK]
Hint: Combine timer and webhook for schedule plus instant build [OK]
Common Mistakes:
  • Using only pollSCM misses instant build
  • Using webhook alone misses scheduled build
  • Polling every minute is inefficient
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard