Scheduling a Jenkins Job

In Jenkins, jobs are scheduled using CRON syntax under the Build Periodically option.

CRON expressions define when a job should run, such as:

  • Nightly
  • Weekly
  • Hourly

Interview-Ready Answer

"We schedule jobs using CRON syntax under Build Periodically. In my project, we scheduled nightly regression using a CRON expression such as 0 2 * * *."

STAR Example

Situation

The regression suite was large and could not run during working hours.

Task

Schedule the Jenkins job to execute automatically at night.

Action

Configured the job using Build Periodically with a CRON expression.

Result

  • Unattended nightly regression
  • Saved manual effort
  • Daily regression coverage

Advertisement

The CRON Format

Jenkins CRON uses 5 fields.

MIN HOUR DAY MONTH WEEKDAY
Field Meaning Range
MIN Minute 0–59
HOUR Hour 0–23
DAY Day of Month 1–31
MONTH Month 1–12
WEEKDAY Day of Week 0–7 (Sun–Sat)

Common CRON Examples

Requirement CRON Syntax
Every Day at 2 AM 0 2 * * *
Every Hour 0 * * * *
Every 15 Minutes */15 * * * *
Every Monday at 9 AM 0 9 * * 1
Nightly Regression 0 1 * * *

Bonus Interview Points

  • Jenkins CRON uses the server time zone.
  • H can be used for load balancing (advanced).
  • CRON is different from Poll SCM.
  • Interviewers prefer real project examples such as nightly regression execution.

Build Periodically vs Poll SCM

The key difference is:

  • Build Periodically executes jobs at fixed time intervals regardless of code changes.
  • Poll SCM checks the repository and starts a build only when changes are detected.

Build Periodically

Characteristics:

  • Uses CRON expressions
  • Executes at fixed schedules
  • Runs even when there are no code changes

Best suited for:

  • Nightly Regression
  • Scheduled Execution
  • Regular Health Checks

Poll SCM

Characteristics:

  • Periodically checks the source code repository
  • Triggers a build only if code changes are found

Best suited for:

  • Git-based projects
  • Automatic build execution after source-code changes

Poll SCM vs Webhook

Poll SCM

Poll SCM is a build-trigger mechanism where Jenkins periodically checks the Source Code Management system (such as Git) for changes.

Analogy

Think of Poll SCM as checking repeatedly whether something has changed.

Typical Flow

  • Configure Poll SCM
  • Configure a CRON schedule (for example, every 15 minutes)
  • Jenkins checks Git at each interval
  • Build starts only if changes are detected

Best Use Case

Useful when webhooks are not available.


Webhook

A webhook allows Git to notify Jenkins immediately whenever code is committed or pushed.

Poll SCM vs Webhook

Poll SCM

  • Jenkins checks Git repeatedly
  • Delayed execution (depends on polling interval)
  • Consumes resources even if nothing changes
  • Useful when webhooks are unavailable

Webhook

  • Git immediately notifies Jenkins
  • Instant build execution
  • Efficient
  • Real-time triggering
  • No unnecessary polling

(Webhook configuration is covered in the Source Code Integration cluster.)


Multiple Triggers

A single Jenkins job can have multiple triggers.

Example:

  • Git Webhook for commit-based execution
  • Build Periodically (CRON) for nightly regression
  • Manual Trigger for on-demand execution

All of these can be configured on the same Jenkins job.


From Real Projects

In my projects I ran Selenium and TestNG suites in batch, group, parallel and cross-browser mode. A CI server like Jenkins is the natural next step: the same suites, triggered automatically after each build or on a schedule, with results published for the whole team. On Canolog, the many forms and screens across sales, inventory, finance and service are where keeping page details in POM classes and reusable steps in a business library paid off. Check the time zone of the Jenkins server before trusting a schedule.

📚 Official documentation: Jenkins documentation

FAQs

How Do You Schedule a Jenkins Job?

Use a CRON expression under the Build Periodically option.

Example:

0 2 * * *

Runs every day at 2:00 AM.


What Is the Jenkins CRON Format?

Jenkins CRON consists of five fields.

MIN HOUR DAY MONTH WEEKDAY

Example:

*/15 * * * *

Runs every 15 minutes.


What Does */15 Mean in CRON?

It means every 15 units of the specified field.

When used in the Minute field, it means:

Every 15 minutes


What Is the Difference Between Build Periodically and Poll SCM?

Build Periodically

  • Executes at fixed schedules
  • Runs regardless of source-code changes

Poll SCM

  • Checks Git periodically
  • Executes only when changes are detected

What Is the Difference Between Poll SCM and Webhook?

Poll SCM

  • Jenkins checks Git repeatedly
  • Delayed execution
  • Uses additional resources

Webhook

  • Git notifies Jenkins instantly
  • Immediate execution
  • More efficient

Can a Jenkins Job Have Multiple Triggers?

Yes.

A single job can use:

  • Git Webhook
  • Build Periodically (CRON)
  • Manual Trigger

at the same time.