Schedule nightly 22-03 build using Jenkins and H, the “hash symbol”

孤街浪徒 提交于 2019-12-05 16:34:30

I think the closest you will get is to use:

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

The H(4-8) construct only works if the second items is larger then the first.

But you might as well fill in the hour yourself. Jenkins actually never changes the hour the jobs runs once it is set. It will basically create some random hour once you save the job and always run the job at that particular time.

Of course, you can also file a bug report or feature request that you should be able to specify this as H(22-3) or better, fix the code and submit a patch ;)

There is no direct support to write the expression like this, but since there is timezone support (now), you can work around this.

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

Above expression means we want to build somewhen between 22 PM and 3 AM, this is a 5 hour period, so we could write:

# Assuming we're in GMT+2 we can just shift the timezone
# so 22-03 becomes 10-15 wich is 12 hours earlier so the
# timezone is GMT-10
TZ=Etc/GMT-10
H H(10-15) * * *

I found this workaround in the comments of JENKINS-18313

UPDATE:

There is currently a bug JENKINS-57702 and the timezone GMT-XX is not evaluated correctly. A workaround is to use a equivalent timezone, in this example the one for Hawaii:

TZ=US/Hawaii
H H(10-15) * * *
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!