Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - Build job monthly or weekly

What is the cron syntax for scheduling a Jenkins job:

a) monthly b) weekly

Thanks!

like image 487
activelearner Avatar asked Apr 27 '15 17:04

activelearner


3 Answers

Jenkins provides a helpful overview here. If you tick on Build periodically in the job configuration, you can click on the question mark next to Schedule.

I just want to quote one small part of it (it's always helpful to read the entire help yourself):

This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace:

MINUTE HOUR DOM MONTH DOW

MINUTE Minutes within the hour (0–59)
HOUR   The hour of the day (0–23)
DOM    The day of the month (1–31)
MONTH  The month (1–12)
DOW    The day of the week (0–7) where 0 and 7 are Sunday.

[...]

In addition, @yearly, @annually, @monthly, @weekly, @daily, @midnight, and @hourly are supported as convenient aliases. These use the hash system for automatic balancing. For example, @hourly is the same as H * * * * and could mean at any time during the hour. @midnight actually means some time between 12:00 AM and 2:59 AM.

like image 53
volker Avatar answered Oct 31 '22 03:10

volker


Jenkins also supports predefined aliases to schedule build:

@hourly, @daily, @weekly, @monthly, @midnight

@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 * *

like image 44
Cyberience Avatar answered Oct 31 '22 05:10

Cyberience


For weekly I successfully use: H 0 * * 0

like image 45
Codev Avatar answered Oct 31 '22 05:10

Codev