How to safe guard against broken jenkinsfiles causing pipelines to run indefinitely?

非 Y 不嫁゛ 提交于 2019-12-11 09:05:43

问题


I have my repo getting polled every 5 mins.

But I found that if the jenkinsfile is totally broken the pipeline will fail with "This stage has no steps".

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?


回答1:


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')
    }
}

Or you could do is trigger the builds from a webhook instead of starting a new build every 5 minutes.

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']])


来源:https://stackoverflow.com/questions/46245605/how-to-safe-guard-against-broken-jenkinsfiles-causing-pipelines-to-run-indefinit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!