Reputation: 718
I make a call like:
and get a result like:
{
"builds": [{
"actions": [{
"parameters": [{
"name": "JT_BUILD_ID",
"value": "1274"
}]
}, {}, {}, {}, {}],
"number": 3,
"result": "SUCCESS"
}, {
"actions": [{
"parameters": [{
"name": "JT_BUILD_ID",
"value": "1273"
}]
}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
"number": 2,
"result": "SUCCESS"
}, {
"actions": [{
"parameters": [{
"name": "JT_BUILD_ID",
"value": "0"
}]
}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
"number": 1,
"result": "SUCCESS"
}]
}
I am passing JT_BUILD_ID so I can match to this run of MYJOB.
When I find the matching JT_BUILD_ID, I look at result and when I see SUCCESS I assume I am done. But the job is still running do to post build actions.
How can I both match the instance of the build (using the parameter JT_BUILD_ID) and detect the final status of the job?
Upvotes: 4
Views: 2967
Reputation: 59963
There is another key building
under builds
, if the post-build is still working, the status will be kept as true
. It turns to false
when the job is totally completed.
Therefore you can add extra check for building == false
, the final url looks like below
The result could be like below in your case if latest build is ongoing (in post-build phase)
{
"builds": [{
"actions": [{
"parameters": [{
"name": "JT_BUILD_ID",
"value": "1274"
}]
}, {}, {}, {}, {}],
"building" : true,
"number": 3,
"result": "SUCCESS"
}, {
"actions": [{
"parameters": [{
"name": "JT_BUILD_ID",
"value": "0"
}]
}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],
"building" : false,
"number": 1,
"result": "SUCCESS"
}]
}
Upvotes: 4