Schedule at night 22-03 using Jenkins and H, the "hash symbol",

The collection, which takes about three hours, should be planned for night construction outside working hours: no earlier than 22:00 and no later than 3:59 the next day.

I would also like to use the “H” symbol to avoid a collision with future nightly builds. From the built-in help in Jenkins:

To allow periodically scheduled tasks to produce a uniform load on the system, the H character should be used (for a "hash") where possible. For example, using 0 0 * * * for a dozen daily tasks will cause a big splash at midnight. On the contrary, using HH * * * would still perform each task once a day, but not all at the same time, better using limited resources.

(How) can I schedule this with Jenkins? What I tried was invalidated by Jenkins:

  • HH(22,23,0,1,2,3) * * *

    Invalid input: "HH (22,23,0,1,2,3) * * *": line 1: 7: waiting "-", found ','

  • H H22,23,0,1,2,3 * * *

    Incorrect input: "H H22,23,0,1,2,3 * * *": line 1: 4: unexpected token: 22

  • HH(22-3) * * *

    Invalid input: "HH (22-3) * * *": line 1: 9: 1 is an invalid value. Must be between 1 and -18

Is it possible to achieve this without using plugins?

+4
source share
2 answers

I think the closest you will use:

  • HH(0-3) * * * This will work at some point between 0:00 and 3:59.
  • @midnight This will work at some point between 0:00 and 2:59.

Construction H (4-8) only works if the second element is larger than the first.

But you could also fill the hour yourself. Jenkins actually never changes the hour of work when the task is completed. This will basically create some random hour after saving the task and always start the task at that particular time.

Of course, you can also file an error report or request for a function, which should be indicated as H(22-3) or better, correct the code and send the patch;)

+7
source

There is no direct support for writing an expression like this, but since there is support for time zones (now), you can get around this.

 # DONT COPY PASTE - THIS DOESNT WORK! # This is what we would like to write, but is not supported HH(22-3) * * * 

The expression above means that we want to build somewhere between 22:00 and 3:00, this is a 5-hour period, so we can write:

 # Assuming we're in GMT+2 we can just shift the timezone by 4 hours # because starting the interval at 18:00 is 4 hours earlier than 22:00 TZ=Etc/GMT+6 HH(18-23) * * * 

I found this workaround in the comments of JENKINS-18313

0
source

Source: https://habr.com/ru/post/1487070/


All Articles