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

112 views
Skip to first unread message

red 888

unread,
Aug 25, 2017, 12:29:34 PM8/25/17
to Jenkins Users
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?

Baptiste Mathus

unread,
Aug 28, 2017, 2:42:16 PM8/28/17
to jenkins...@googlegroups.com
Yes and no. No, nothing specific to pipeline springs to my mind for this.
But yes, is very easy to use system Groovy script to, for instance, find the recent builds that failed in less than 5 seconds.

Something like (untested, on the phone):

Jenkins.instance.allItems
.findAll { it instanceof SomeProject, filter what you want }
.collect { it.builds }
.flatten()
.findAll { it.state = failed && it.duration < 5000 }
.each { println it.job.name }

Beware that the code above is totally untested and partly pseudo code, so you need to complete it.

Sure ask again if you can't get it finished.

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3d788f3a-2764-4756-9b66-e22c600e2029%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages