如何安排詹金斯的工作? [英] How do I schedule jobs in Jenkins?

查看:113
本文介绍了如何安排詹金斯的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在詹金斯(Jenkins)添加了一份新工作,我想定期安排该工作.

I added a new job in Jenkins, which I want to schedule periodically.

配置作业中,我选中定期构建"复选框,并在 Schedule 文本字段中添加了表达式:

From Configure job, I am checking the "Build Periodically" checkbox and in the Schedule text field added the expression:

15 13 * * *

15 13 * * *

但是它不能在计划的时间运行.

But it does not run at the scheduled time.

安排工作是否正确?

该作业应在4:20 AM运行,但未运行.

The job should run at 4:20 AM, but it is not running.

推荐答案

通过将计划期设置为15 13 * * *,您告诉Jenkins在每年第13个小时的第15分钟的第15分钟安排建设计划一天.

By setting the schedule period to 15 13 * * * you tell Jenkins to schedule the build every day of every month of every year at the 15th minute of the 13th hour of the day.

Jenkins使用了 cron表达式,并且不同的字段是:

Jenkins used a cron expression, and the different fields are:

  1. MINUTES一小时内的分钟数(0-59)
  2. 一天中的小时数(0-23)
  3. DAYMONTH一个月中的某天(1-31)
  4. 一年中的MONTH月(1-12)
  5. DAYWEEK星期几(0-7),其中0和7是星期天

如果您希望每5分钟安排一次构建,这将完成工作:*/5 * * * *

If you want to schedule your build every 5 minutes, this will do the job : */5 * * * *

如果您希望每天8h安排构建,这将完成工作:0 8 * * *

If you want to schedule your build every day at 8h00, this will do the job : 0 8 * * *

在过去的几个版本(2014年)中,詹金斯有一个新参数H(摘录自

For the past few versions (2014), Jenkins have a new parameter, H (extract from the Jenkins code documentation):

为使定期执行的任务在系统上产生均匀的负载,应尽可能使用符号H(用于哈希").

To allow periodically scheduled tasks to produce even load on the system, the symbol H (for "hash") should be used wherever possible.

例如,使用0 0 * * *进行许多日常工作将导致午夜时分大幅增加.相比之下,使用H H * * *仍然可以每天执行一次每个作业,但不能同时执行所有作业,最好使用有限的资源.

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.

还请注意:

可以将H符号视为一个范围内的随机值,但实际上它是作业名称的哈希,而不是随机函数,因此该值对于任何给定的项目都保持稳定.

The H symbol can be thought of as a random value over a range, but it actually is a hash of the job name, not a random function, so that the value remains stable for any given project.

使用"H"的更多示例

这篇关于如何安排詹金斯的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆