How do I schedule releases for continuous integration with Jenkins?

10

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

* 3 * * *

Letting it in this way generated a lot of build during 03:00 and 04:00, could someone 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 this logic, but it did not work.

    
asked by anonymous 08.01.2014 / 10:39

2 answers

6

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

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

Detailing:

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

That is, you specify what time of the hour you want it to run, and at what time. The rest you leave as * (applies to all). The second statement (time) can be simplified as follows:

0 */3 * * *

In this case, the 1-12 means "every three hours" - but without specifying the starting time. In this case, I'm not sure what times the task would run, except that there will be a 3-hour interval between one run and another.

This * can also be replaced by an explicit range. A more complex example:

15 0-6/2 * * 0,3

"Every Sunday and every Wednesday, every two hours at dawn, at the 15th minute" That is: 0-6 , 0 , * and */3 (notice the interval is closed) / p>

Note: This answer assumes that Jenkins implements the Cron correctly and completely; if only one subset is supported, some of the above options may not be available. I suggest you run some tests to determine if a particular statement works as expected.

    
08.01.2014 / 11:32
1

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

It has been tested on Jenkins version 1.612

    
24.07.2015 / 18:07