Under Build Triggers - Build periodically - Schedule you can create a schedule (or multiple schedules) for Jenkins to build periodically or on a specific date/time.
It might be tests that should be run periodically (every morning for example) or a DB clean up Jenkins job or any other Jenkins job.
To set periodically scheduled Jenkins jobs you should use Configure - Build Triggers - Build periodically - Schedule
If you have many different Jenkins jobs that may need to be built periodically or by special schedules and limited resources I recommend to use H in every Jenkins schedule where it’s possible to avoid spikes.
Jenkins build periodically - examples
Build every hour: H * * * *
Build every 20 minutes: H/20 * * * *
Build every 20 minutes 5am to 11pm: H/20 5-23 * * *
Build every 20 minutes, work time/days (8am-6pm, MON-FRI) only: H/20 8-18 * * 1-5
Build every hour MON-WED and FRI only: H * * * 1-3,5
Build every hour, weekends in April and December: H * * 4,12 *
Build at 8.30am on July 4: 30 8 4 7 *
Jenkins schedule format
Jenkins schedule format is nothing but a cron schedule expression. It contains 5 fields
Note: Taken from Cron
Jenkins build periodically - predefined aliases
Jenkins also supports predefined aliases to schedule build: @hourly, @daily, @weekly, @monthly, @midnight
Schedule Alias | Schedule Description | Schedule command |
---|---|---|
@hourly | Build every hour at the beginning of the hour | 0 * * * * |
@daily, @midnight | Build every day at midnight | 0 0 * * * |
@weekly | Build every week at midnight on Sunday morning | 0 0 * * 0 |
@monthly | Build every month at midnight of the first day of the month | 0 0 1 * * |
Jenkins build periodically - multiple schedules
You can apply even more than one schedule for a Jenkins job.
For example you might have a regular schedule to build Jenkins periodically, let’s say we want to build periodically every work day’s like this
30 8 * * 1-5
Let’s assume we need to build Jenkins periodically every week before weekend starts.
30 16 * * 5
Now we can easily combine these two Jenkins schedules
30 8 * * 1-5
30 16 * * 5
Jenkins will build every work day at 8:30am and every week on Friday at 4:30pm
You may also find these posts interesting: