Disable new jobs if a build fails

32 views
Skip to first unread message

Idan Adar

unread,
Apr 3, 2017, 9:11:36 AM4/3/17
to Jenkins Users
Hello,

I received a request, which sounds kinda far-fetched to me, but maybe I wrong.

Lets assume there is a job that is scheduled to run 3 times ago. End to end sort of tests. And at some point one of the job runs fails.
The request here is to block all future PRs for any repository in GitHub from triggering their respective jobs (each repo has a Jenkinsfile, a PR triggers it).

Is this at all possible? Blocking all jobs until an error is fixed?

Maciej Jaros

unread,
Apr 4, 2017, 4:35:41 AM4/4/17
to jenkins...@googlegroups.com
Idan Adar (2017-04-03 15:11):
I think you would have to manually enable builds after the error is fixed, but you can disable builds with Groovy:
def job = Jenkins.instance.getItem("your-job-name");
job.disable()
//job.enable()

Regards,
Nux.

Idan Adar

unread,
Apr 4, 2017, 5:07:55 AM4/4/17
to jenkins...@googlegroups.com
Thanks!

I looked at the job, which is a multi-branch pipeline, and I did not see any disable or enable button. So assume the job does get somehow disabled via code, how would I enable it (manually)? only by code?

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/YcdTo2AZgiA/unsubscribe.
To unsubscribe from this group and all its topics, 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/f5fecaad-dbc3-d665-c35f-15e97345d2fa%40mol.com.pl.

For more options, visit https://groups.google.com/d/optout.



--
Idan Adar

Idan Adar

unread,
Apr 5, 2017, 4:29:43 AM4/5/17
to Jenkins Users
Looks like this is the solution: https://issues.jenkins-ci.org/browse/JENKINS-27299
But only once it actually get merged. Otherwise this is a no-go for multi-branch pipelines...


On Tuesday, April 4, 2017 at 12:07:55 PM UTC+3, Idan Adar wrote:
Thanks!

I looked at the job, which is a multi-branch pipeline, and I did not see any disable or enable button. So assume the job does get somehow disabled via code, how would I enable it (manually)? only by code?
Reply all
Reply to author
Forward
0 new messages