0
0
JenkinsHow-ToBeginner · 3 min read

How to Schedule Build in Jenkins: Simple Guide

To schedule a build in Jenkins, go to your job's configuration page and enable Build periodically. Then, enter a cron-style schedule expression in the Schedule field to define when Jenkins should run the build automatically.
📐

Syntax

The Jenkins build schedule uses a cron-like syntax with five fields separated by spaces:

  • MINUTES (0-59)
  • HOURS (0-23)
  • DAY OF MONTH (1-31)
  • MONTH (1-12)
  • DAY OF WEEK (0-7, where both 0 and 7 mean Sunday)

Each field can be a single number, a range, a list, or a wildcard * to mean 'every'.

plaintext
MINUTES HOURS DAY_OF_MONTH MONTH DAY_OF_WEEK
*       *     *            *     *
💻

Example

This example schedules a Jenkins job to run every day at 2:30 AM.

plaintext
30 2 * * *
Output
The job will run daily at 2:30 AM.
⚠️

Common Pitfalls

Common mistakes when scheduling builds in Jenkins include:

  • Using incorrect cron syntax, causing the job not to run.
  • Forgetting to enable the Build periodically option.
  • Confusing DAY OF MONTH and DAY OF WEEK fields, which can cause unexpected schedules.
  • Using the @daily or other shortcuts which Jenkins does not support.

Always test your schedule with simple expressions first.

plaintext
Wrong: 30 2 * * 8  # Invalid day of week
Right: 30 2 * * 0   # Sunday is 0 or 7
📊

Quick Reference

FieldAllowed ValuesDescription
MINUTES0-59Minute of the hour
HOURS0-23Hour of the day
DAY OF MONTH1-31Day of the month
MONTH1-12Month of the year
DAY OF WEEK0-7Day of the week (0 or 7 = Sunday)

Key Takeaways

Enable 'Build periodically' in Jenkins job configuration to schedule builds.
Use cron syntax with five fields: minutes, hours, day of month, month, day of week.
Test your cron expression with simple schedules before complex ones.
Remember Sunday can be 0 or 7 in the day of week field.
Avoid unsupported shortcuts like '@daily' in Jenkins cron schedules.