如何在Jenkins安排工作 [英] How to schedule jobs in Jenkins

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

问题描述

我在Jenkins中添加了一个新的工作,我想定期安排

I added a new Job in Jenkins, which i want to schedule periodically

在配置作业中,我检查定期构建复选框, - 文本字段添加了表达式

From the configure job, i am checking the "Build Periodically" checkbox and in the Schedule - text field added the expression


15 13 * * *

15 13 * * *


b $ b

但它不会在预定时间运行。

But it does not run @ the scheduled time.

这是计划作业的正确程序吗?请纠正我。

Is it the correct procedure to schedule a job? Please correct me.

>

作业应该在上午4:20运行,但它不运行。

The job should run @ 4:20 AM, but its not running.

推荐答案

通过将日程安排期设置为 15 13 * * * ,您可以告诉jenkins在每天的第13个小时的每个月的第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表达式,不同的字段为:

What Jenkins used is a cron expression, the different fields are :


  1. MINUTES一小时内的分钟数(0-59)

  2. HOURS一天内的时间(0-23)

  3. DAYMONTH一天中的某一天(1-31)

  4. MONTH月(1-12)

  5. DAYWEEK星期几(0-7),其中0和7是星期日

  1. MINUTES Minutes in one hour (0-59)
  2. HOURS Hours in one day (0-23)
  3. DAYMONTH Day in a month (1-31)
  4. MONTH Month in a year (1-12)
  5. DAYWEEK Day of the week (0-7) where 0 and 7 are sunday

如果你想每5分钟安排一次构建,这将执行: * / 5 * * * *

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

如果你想每天在8h00安排你的构建,这将做的工作: 0 8 * * *

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

从2014年6月开始编辑:
从几个版本开始,Jenkins添加了一个新参数 H : href =https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/hudson/triggers/TimerTrigger/help-spec.html =nofollow noreferrer> jenkins代码文档)

Edit from June 2014 : since a few versions, Jenkins add a new parameter, H : (extract from the jenkins code documentation)


为了允许定期计划的任务在系统上产生均匀的负载,符号 H (对于hash)应尽可能使用。

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

例如,对于十几个日常工作,使用 0 0 * * * 会在午夜产生大的尖峰。相反,使用 HH * * * 仍然每天执行一次作业一次,但不是全部同时执行,更好地使用有限的资源。

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'的示例

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

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