How to schedule releases on continuous integration with Jenkins?

Asked

Viewed 3,697 times

10

I’m using the Jenkins tool for continuous integration, it’s working normally. I tried to leave scheduled to build every 3 hours, so I checked the checkbox "Build periodically" and left as follows:

* 3 * * *

Leaving the same way generated several build during 03:00 and 04:00, someone would know tell me which command to leave generating automatic build every 3 hours?

In Jenkins himself he gives the following example:

Exemplos    
# todo minuto
* * * * *
# no minuto 5 de cada hora (ou seja '2:05,3:05,...') 
5 * * * *

I tried to follow that logic, but it didn’t work.

2 answers

7


Apparently Jeninks is using the cron format, common on Linux systems. So what your instruction is saying is: "perform the task once every minute (*) of the hour 3, every day (*), every month (*), any day of the week (*)". For your task to run every 3 hours, a way would be:

0 0,3,6,9,12,15,18,21 * * *

Detailing:

  • 0 - the task will always run at zero minute (accepted 0-59);
  • 0,3,6,9,12,15,18,21 - the task will run at zero hour, at three, at six... (accepts 0-23);
  • * - the task will run every day (accepted 1-31);
  • * - the task will run every month (accepted 1-12);
  • * - the task will perform any day of the week (accepted 0-6, where 0 is "Sunday").

That is, you specify in which minute of the hour you want it to run, and in what hours. The rest you leave as * (applies to all). The second instruction (hour) can be simplified in this way:

0 */3 * * *

In that case the */3 means "every three [hours]" - but without specifying the initial time. In this case, I’m not sure at what times the task would perform, except that there will be a 3-hour interval between one execution and another.

That one * can also be replaced by an explicit interval. A more complex example:

15 0-6/2 * * 0,3

"Every Sunday and every Wednesday, every two hours at dawn, at minute 15" That is to say: 00:15, 02:15, 04:15 and 06:15 (note that the interval is closed).


Note: this answer assumes that Jenkins correctly and fully implements the Cron format; if only one subset If supported, some of the above options may not be available. I suggest you run some tests to determine if a certain instruction works as expected.

1

The standard to repeat every 3 hours is: H */3 * * *.

Tested on Jenkins version 1.612

Browser other questions tagged

You are not signed in. Login or sign up in order to post.