如何在 Jenkins 中安排构建? [英] How to schedule a build in Jenkins?

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

问题描述

如何安排 Jenkins 构建,使其只能在每天的特定时间构建?

How do I schedule a Jenkins build such that it would be able to build only at specific hours every day?

例如下午 4 点开始

0 16 1-7 * *

我理解为每个月的星期一到星期日的 0 分钟,下午 4 点",但是它每分钟都会建立:(

I understand that as, "at 0 minutes, at 4 o'clock PM, from Monday to Sunday, every month", however it builds every minute :(

如果您有任何建议,我将不胜感激.谢谢!

I would be grateful for any advice. Thanks!

推荐答案

请阅读其他答案和评论,这里有很多我在回答时不知道的信息陈述和细微差别(哈希函数?)这个问题.

根据Jenkins自己对scheduling task的帮助(?"按钮),指定了5个字段:

According to Jenkins' own help (the "?" button) for the schedule task, 5 fields are specified:

该字段遵循 cron 的语法(略有不同).具体来说,每行由 5 个字段组成,由 TAB 或空格分隔:分钟 DOM 月 DOW

This field follows the syntax of cron (with minor differences). Specifically, each line consists of 5 fields separated by TAB or whitespace: MINUTE HOUR DOM MONTH DOW

我只是尝试在下午 4 点 42 分(我的大致当地时间)启动一项工作,结果如下所示,尽管多花了大约 30 秒:

I just tried to get a job to launch at 4:42PM (my approximate local time) and it worked with the following, though it took about 30 extra seconds:

42 16 * * *

如果你想要多次,我认为以下应该有效:

If you want multiple times, I think the following should work:

0 16,18,20,22 * * *

每天下午 4 点、6 点、8 点和 10 点.

for 4, 6, 8, and 10 o'clock PM every day.

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

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