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: 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!
This example is everyday, once around 9am and once around 5pm. (edited per comments).
That appears to be a cron expression. Note that your example builds only on the first to seventh of every month, at 16:00. You likely have some sort of other error, or Jenkins uses non-standard CRON expressions.
MON-FRI build every 2 hour between
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:
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:
If you want multiple times, I think the following should work:
for 4, 6, 8, and 10 o'clock PM every day.
Jenkins uses Cron Expressions.
You can simply schedule hourly builds by just typing:
@hourly
In the job configuration one can define various build triggers. With periodically build you can schedule the build by defining the date or day of the week and the time to execute the build.
The format is as follows:
The letter H, representing the word Hash can be inserted instead of any of the values, it will calculate the parameter based on the hash code of your project name, this is so that if you are building several projects on your build machine at the same time, lets say midnight each day, they do not all start there build execution at the same time, each project starts its execution at a different minute depending on its hash code. You can also specify the value to be between numbers, i.e. H(0,30) will return the hash code of the project where the possible hashes are 0-30
Examples:
start build daily at 08:30 in the morning, Monday - Friday:
weekday daily build twice a day, at lunchtime 12:00 and midnight 00:00, Sunday to Thursday:
start build daily in the late afternoon between 4:00 p.m. - 4:59 p.m. or 16:00 -16:59 depending on the projects hash:
start build at midnight:
or start build at midnight, every Saturday:
every first of every month between 2:00 a.m. - 02:30 a.m. :
more on CRON expressions