我可以限制民意调查SCM作业每天仅运行一次吗? [英] Can I restrict poll SCM job to be run only once in a day?

查看:117
本文介绍了我可以限制民意调查SCM作业每天仅运行一次吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个民意调查SCM作业,该作业每5分钟轮询一次Perforce的变化.但是我只需要在一天中对perforce中的文件进行第一次编辑时才触发作业.我可以限制民意调查SCM作业每天仅运行一次吗?

I have a poll SCM job , which polls every 5 minutes for a change in Perforce. But I need the job to be triggered only when first edit happens for the files in perforce in a day. Can I restrict poll SCM job to be run only once in a day?

推荐答案

詹金斯(Jenkins)本身不提供这种行为(每天仅针对第一个更改运行").

Jenkins itself does not provide this kind of behaviour ("run only for the very first change every day").

您需要将其分为两部分;第一个是轮询SCM,第二个要注意该作业每天运行不超过一次.

You need to split this down into two parts; the first one polling SCM, the second taking care that the job will not run more than once per day.

可能的解决方案:

  • 保留当前的轮询工作,每5分钟检查一次更改
  • 添加一个构建步骤,该步骤将在运行后禁用作业(从而防止在这一天再次运行)
  • 创建另一个作业,该作业每天早晨在0:00处(重新)启用轮询作业,以便轮询作业可以在下一次更改时运行

如果您不希望轮询作业进入禁用"状态,则还可以在运行结束时从作业配置中删除该作业的SCM轮询,并让第二个作业重新建立该作业. .这有点复杂,因为您需要修改作业配置.

If you don't like to see the polling job going into "disabled" state, then you could also remove the job's SCM polling from the job configuration at the end of the run, and have the second job re-establish that. This is a bit more complicated as you need to modify the job configuration.

在任何情况下,更改"将始终指代轮询作业的最后一次运行.因此,如果在第1天有A和B两个更改,则轮询作业将在第1天对"A"运行一次,然后在第2天立即对"B"再次运行.

In any case, "change" will always refer to the last run of the polling job. So if there's two changes A and B on day 1, then the polling job will run once for "A" on day 1, and then immediately again for "B" on day 2.

这篇关于我可以限制民意调查SCM作业每天仅运行一次吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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