问题
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