Groovy web console

subscribe to the feed Subscribe
to this
site

Franco

Published 5 months ago by Franco
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonSlurper
String json = '{"_class":"hudson.model.FreeStyleProject","builds":[{"_class":"hudson.model.FreeStyleBuild","id":"860","number":860,"queueId":8777305,"result":null},{"_class":"hudson.model.FreeStyleBuild","id":"859","number":859,"queueId":8777236,"result":null},{"_class":"hudson.model.FreeStyleBuild","id":"858","number":858,"queueId":8777173,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"857","number":857,"queueId":8777102,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"856","number":856,"queueId":8776924,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"855","number":855,"queueId":8776913,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"854","number":854,"queueId":8776839,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"853","number":853,"queueId":8776795,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"852","number":852,"queueId":8776713,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"851","number":851,"queueId":8776683,"result":"SUCCESS"},{"_class":"hudson.model.FreeStyleBuild","id":"850","number":850,"queueId":8776648,"result":"SUCCESS"}]}'

def slurper = new JsonSlurper()
def object = slurper.parseText(json)

println object.builds.findAll{it.queueId == 8777236}