I have been doing some work on scraping the failed builds out of our Jenkins instance, and then trying to match up failures, including ones categorized by the Build Failure Analyzer, and I can tell you it is a bit frustrating.
We have three types of builds (FreeStyle, Matrix, and Workflow) and each of them reports things differently. Tim's comment bout using depth=3
on the API works, but I have been using the more specific:
https://HOST_NAME/job/PROJECT_NAME/api/json?pretty=true&tree=allBuilds[number,timestamp,url,duration,result,runs[url,number],actions[foundFailureCauses[*]]]
The tree
part makes better sure you get all the parts you want (sometimes the depth
does not get thing that this does), as well as excluding things you don't. This works for FreeStyle builds, and Workflow builds that terminate with a single node.
For Matrix builds you then have to follow the links provided in runs
, but you have to munch the URL it gives you (it puts the build number in the wrong place). Then you call the same API on the linked build to scrape out that one.
For Workflow builds there is annoying news, good news, bad news, and even worse news as far as I know. The annyoying part is that you have to see that this is a Workflow build (look at the _class
property that you got without asking for it), and then look at the build url, but replacing wfapi
for api/json
(and forgetting the rest of the parameters). Then you can follow the json
links that you get back form that to locate the failures. The good news is that this gives you a much better link to the failure, including intelligible messages (sometime).
The bad news is that I am not sure that the Build Failure Analyzer is working properly for these, or knows how to mark it on the proper build step.
The even worse news is that for a lot of builds on my server this API does not seem to work at all. This is even though I can see similar information through the BlueOcean UI. I am investigating running this down now.
Sorry that this is not a simple answer, but that is the state of things as far as I can tell at this point.