Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to schedule a build in Jenkins?

How do I schedule a Jenkins build such that it would be able to build only at specific hours every day?

For example to start at 4 PM

0 16 1-7 * * 

I understand that as, "at 0 minutes, at 4 o'clock PM, from Monday to Sunday, every month", however it builds every minute :(

I would be grateful for any advice. Thanks!

like image 867
deadfish Avatar asked Aug 09 '11 17:08

deadfish


People also ask

How do I trigger a build automatically in Jenkins?

Follow the steps as mentioned below to trigger a Jenkins job automatically based on GitHub's webhook configurations: Step 1: Go to the Configuration page of the respective job and under the build trigger section, check the "GitHub hook trigger for GITScm polling" checkbox and click on the Save button.

Can Jenkins be used as a scheduler?

For example, you may use source control to manage configuration data that you want to deploy to production daily or weekly. However, instead of having systems “pull” these configurations from source control with locally scheduled cron jobs, you can use Jenkins to act as a central scheduler.


1 Answers

Please read the other answers and comments, there’s a lot more information stated and nuances described (hash functions?) that I did not know when I answered this question.

According to Jenkins' own help (the "?" button) for the schedule task, 5 fields are specified:

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

I just tried to get a job to launch at 4:42PM (my approximate local time) and it worked with the following, though it took about 30 extra seconds:

42 16 * * * 

If you want multiple times, I think the following should work:

0 16,18,20,22 * * * 

for 4, 6, 8, and 10 o'clock PM every day.

like image 129
Zach Young Avatar answered Sep 19 '22 04:09

Zach Young