Skip to content

Instantly share code, notes, and snippets.

@kellyrob99
Created December 4, 2011 18:03
Show Gist options
  • Save kellyrob99/1430845 to your computer and use it in GitHub Desktop.
Save kellyrob99/1430845 to your computer and use it in GitHub Desktop.
A script to find the source control version of the last successful build on every Jenkins job for a particular server. Outputs whether or not each job is building the expectedVersion.
import groovy.json.JsonSlurper
assert args && args.size() == 2
def urls = args[0].split(',')
def expectedVersion = args[1]
urls.each { url ->
println "examining url $url"
def json = new JsonSlurper().parseText(url.toURL().text)
json.jobs.each {
try
{
def job = new JsonSlurper().parseText("${it.url}/api/json?depth=1".toURL().text)
if (!job.builds[0].changeSet.revisions[0].module.endsWith(expectedVersion))
{
println "$it.url fails!"
}
else
{
println "$it.url passes!"
}
}
catch (e)
{
println "Exception thrown processing $it.url : $e"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment