如何防范损坏的jenkinsfiles导致管道无限期运行? [英] How to safe guard against broken jenkinsfiles causing pipelines to run indefinitely?
问题描述
我的存储库每5分钟被轮询一次.
I have my repo getting polled every 5 mins.
但是我发现,如果jenkinsfile完全损坏,则管道将失败,并显示此阶段没有步骤".
But I found that if the jenkinsfile is totally broken the pipeline will fail with "This stage has no steps".
然后每5分钟重试一次并保持失败.
Then every 5 mins it will retry it and keep failing.
我该如何防范呢?我可以在某个地方设置阈值,以便这种情况不会永远消失吗?
How do I safe guard against this? Can I set a threshold somewhere so if this happens it doesn't churn forever?
推荐答案
如果使用的是scm轮询,则只有在进行更改的情况下才可以构建.听起来您可能正在按计划进行计划.这是声明性管道中每种语法的不同语法.
If you are using scm polling, it should only build if there are changes. Sounds like you may be building on a cron schedule. Here is the different syntax for each in a declarative pipeline.
pipeline {
triggers {
cron('H/4 * * * 1-5')
pollSCM('0 0 * * 0')
}
}
或者您可以做的是从Webhook触发构建,而不是每5分钟启动一次新构建.
Or you could do is trigger the builds from a webhook instead of starting a new build every 5 minutes.
如果您真的只想限制构建,以至于在 x 时间内只能完成 n 个构建,则可以设置以下属性:
If you really just want to throttle the builds so you can't do more than n builds in x time, you can set this property:
properties([[$class: 'JobPropertyImpl', throttle: [count: 1, durationName: 'hour']])
这篇关于如何防范损坏的jenkinsfiles导致管道无限期运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!