使用詹金斯(Jenkins)和H(哈希符号)

使用詹金斯(Jenkins)和H(哈希符号)

问题描述:

需要安排大约三个小时才能完成的建筑,以安排在办公时间以外的夜间进行:第二天不早于22:00,第二天不晚于3:59.

A build that takes about three hours to complete needs to be scheduled for nightly building outside office hours: not sooner than 22:00 and not later than 3:59 next day.

我还想使用"H符号"来避免与以后的夜间版本相冲突.从詹金斯的在线帮助中:

I'd also like to use the "H symbol" to avoid collision with future nightly builds. From in-line help in Jenkins:

为使定期计划的任务在系统上产生均匀的负载,应尽可能使用符号H(哈希").例如,将0 0 * * *用于一打日常工作,将导致午夜时分大幅增加.相比之下,使用H H * * *仍会每天执行一次每个作业,但不能同时执行所有作业,最好使用有限的资源.

To allow periodically scheduled tasks to produce even load on the system, the symbol H (for "hash") should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.

(如何)使用Jenkins安排时间?詹金斯认为我尝试过的一切都是无效的:

(How) can I schedule this using Jenkins? What I've tried was all considered invalid by Jenkins:

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

无效输入:"H H(22,23,0,1,2,3)* * *":第1:7行:期望为-",找到了,"

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

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

    无效输入:"H H22,23,0,1,2,3 * * *":第1:4行:意外令牌:22

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

  • H H(22-3) * * *

    无效输入:"H H(22-3)* * *":第1:9行:1是无效值.必须在1之内 和-18

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

  • 是否可以在不使用插件的情况下实现这一目标?

    Is it possible to achieve this without using plug-ins?

    我认为最接近的方法是使用:

    I think the closest you will get is to use:

    • H H(0-3) * * *这将在0:00和3:59之间的某个时间运行
    • @midnight这将在0:00和2:59之间的某个时间运行
    • 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

    H(4-8)构造仅在第二个项目比第一个项目大时起作用.

    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.

    当然,您还可以提交错误报告或功能请求,以使它可以指定为H(22-3)或更高,修复代码并提交补丁;)

    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 ;)