Difference between revisions of "Failed Jobs"

From Eclipsepedia

Jump to: navigation, search
(New page: This scripts displays a list of all failed jobs. Addon: restart them. <pre> // Get the list of failed jobs activeJobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()}...)
 
(add some context)
 
Line 1: Line 1:
This scripts displays a list of all failed jobs. Addon: restart them.
+
This [[Hudson]] script displays a list of all failed jobs. Addon: restart them.
 
<pre>
 
<pre>
 
// Get the list of failed jobs
 
// Get the list of failed jobs
Line 24: Line 24:
 
joblist.each{run -> run.scheduleBuild(cause)}
 
joblist.each{run -> run.scheduleBuild(cause)}
 
</pre>
 
</pre>
 +
 +
[[Category:Hudson]]

Latest revision as of 11:01, 19 July 2013

This Hudson script displays a list of all failed jobs. Addon: restart them.

// Get the list of failed jobs
activeJobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable()}
failedRuns = activeJobs.findAll{job -> job.lastBuild != null && job.lastBuild.result == hudson.model.Result.FAILURE}
// Do something with them - e.g. listing them
failedRuns.each{run -> println(run.name)}

Sample ouput produced:

ProjectA
ProjectB
ProjectC
Result: [hudson.model.FreeStyleProject@1f39c59[ProjectA], hudson.model.FreeStyleProject@16a93b8[ProjectB], hudson.model.FreeStyleProject@12947ee[ProjectC]]

[edit] Addons

If you have a list of failed jobs you also could do other things than just printing them. The key is changing the last closure.

[edit] Addon: Restart

startServer = "admin computer"
startNote   = "bulk start"
cause = new hudson.model.Cause.RemoteCause(startServer, startNote)
joblist.each{run -> run.scheduleBuild(cause)}