Created
February 26, 2012 00:44
-
-
Save kellyrob99/1911932 to your computer and use it in GitHub Desktop.
Find and trigger all failed builds on a machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @GrabResolver(name = 'glassfish', root = 'http://maven.glassfish.org/content/groups/public/') | |
| @GrabResolver(name = "github", root = "http://kellyrob99.github.com/Jenkins-api-tour/repository") | |
| @Grab('org.kar:hudson-api:0.2-SNAPSHOT') | |
| @GrabExclude('org.codehaus.groovy:groovy') | |
| import org.kar.hudson.api.cli.HudsonCliApi | |
| String rootUrl = 'http://localhost:8080' | |
| HudsonCliApi cliApi = new HudsonCliApi() | |
| OutputStream out = new ByteArrayOutputStream() | |
| def script = '''hudson.items.findAll{ job -> | |
| job.isBuildable() && job.lastBuild && job.lastBuild.result == Result.FAILURE | |
| }.collect{it.name}.inspect() | |
| ''' | |
| cliApi.runCliCommand(rootUrl, ['groovysh', script], System.in, out, System.err) | |
| List failedJobs = Eval.me(cliApi.parseResponse(out.toString())) | |
| failedJobs.each{ job -> | |
| cliApi.runCliCommand(rootUrl, ['build', job]) | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment