It's all about the answers!

Ask a question

How can I get result for a specific build request using REST api?

Michele Pegoraro (1.8k14117103) | asked May 12 '14, 12:12 p.m.
I'm looking for a way to get a specific build result through REST api. The scenario is: I launch a build using REST api, and then get the RequestUUID. I'd like to query this single build request result.
Currently I'm requesting all the build results for a single build definition and then parsing it using regex. But I've problem with this exception:

Build result handles array can not exceed 512 elements

512 build results is not enough for my client so reducing purge policy is not a way I can use.

Is it possible to query single request results?


Accepted answer

permanent link
Nick Edgar (6.5k711) | answered May 12 '14, 12:41 p.m.
edited May 12 '14, 12:45 p.m.
Hi Michele.  The REST interface should really return both the build request UUID and the build result UUID.  Feel free to open an enhancement request for this.  Also, please file an item for the 'cannot exceed 512 elements' and we can follow up on that separately.

One workaround is to fetch the BuildRequest item via the .../itemOid/... URL, e.g.
    "buildResult": {
        "": "",
        "itemId": "_MXhtQcdvEeO185rLDU7C-w",
        "uri": "itemOid\/\/_MXhtQcdvEeO185rLDU7C-w"
Michele Pegoraro selected this answer as the correct answer

Nick Edgar commented May 12 '14, 12:44 p.m.

Note that the _mediaType and _prettyPrint query args are just for debugging. In a programmatic request you would specify an Accept header with text/json. 

Michele Pegoraro commented May 15 '14, 6:13 a.m.

Thanks Nick for your answer. Once I've the buildResult itemId how can I get the complete element (for example to get buildResult status SUCCESSFUL/FAILED)? Can I use  this uri I have in return from buildRequest call?

Nick Edgar commented May 15 '14, 12:09 p.m.

You can either request .../resource/virtual/build/result/[result itemID UUID] or .../resource/itemOid/[result itemID UUID]. The latter normally redirects to the web UI when pasted into a browser, but if requesting with Accept header of text/xml or text/json, it'll give you the item.  There's also .../resource/virtual/build/resultrecord/[result itemID UUID] which gives more info including the request item.

Michele Pegoraro commented May 19 '14, 10:37 a.m.

Thanks Nick. I will use this way.

Your answer

Register or to post your answer.