Course contentsShow
← Cloud and Infrastructure
Lesson 1789 of 2,98937. JenkinsFree lesson

Triggers and Automated Execution

Configure automatic pipeline execution using SCM polling, webhooks, cron schedules, and upstream jobs.

Triggers and Automated Execution

What you'll learn: How to make Jenkins pipelines run automatically instead of clicking "Build Now" every time.

The Core Idea

Triggers tell Jenkins when to start your pipeline without manual intervention. Think of them like alarm clocks for your builds—you set the conditions, and Jenkins wakes up and runs when those conditions are met. This is essential for true CI/CD automation where code changes immediately kick off testing and deployment.

Four Main Trigger Types

SCM Polling checks your source code repository at regular intervals (e.g., every 5 minutes). If Jenkins detects new commits, it starts a build. You configure this with a cron-like schedule:

triggers {
    pollSCM('H/5 * * * *')  // Check every 5 minutes
}

Webhooks (push notifications) are smarter—your Git server immediately notifies Jenkins when code is pushed. No polling delay, faster feedback. Configure these in your Git provider's settings pointing to your Jenkins URL.

Cron Schedules run builds at specific times, regardless of code changes:

triggers {
    cron('0 2 * * *')  // Every night at 2 AM
}

Perfect for nightly builds or scheduled deployments.

Upstream Jobs trigger when another Jenkins job completes successfully:

triggers {
    upstream(upstreamProjects: 'build-job', threshold: hudson.model.Result.SUCCESS)
}

This creates deployment chains: build → test → deploy.

Combining Triggers

You can use multiple triggers together. A pipeline might poll SCM during work hours and run a full test suite nightly via cron.

Key Takeaway: Triggers transform Jenkins from a manual build tool into an automated CI/CD engine—use SCM polling or webhooks for code changes, cron for scheduled tasks, and upstream triggers for job chaining.