I am trying to parse through some JSON and get the status from 'stop-emu'.
def stageJson = new JsonSlurper().parseText(response?.content)
stageJson.stages.each { echo(it) }
//status = ????
the code above returns the following:
16:49:47 [_links:[self:test], id:2, name:test_name, execNode:none, status:SUCCESS, pauseDurationMillis:0]
[Pipeline] echo
16:49:47 [_links:[self:test], id:5, name:test_name, execNode:none, status:SUCCESS, pauseDurationMillis:0]
[Pipeline] echo
16:49:47 [_links:[self:test], id:6, name:stop-emu, execNode:none, status:FAILED, pauseDurationMillis:0]
[Pipeline] echo
16:49:47 [_links:[self:test], id:100, name:del-work, execNode:none, status:SUCCESS, pauseDurationMillis:0]
[Pipeline] echo
I'm halfway there, just not sure how to grab the status if name = stop-emu.
to find the first one
stageJson.stages.find{it.name=='stop-emu'}?.status
if you have and need to collect all of them:
stageJson.stages.findAll{it.name=='stop-emu'}.collect{it.status}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.