Get total test count via rest api

Hello,

is it possible to find recursively the total test count for latest success builds (per build configuration) under specific project and its subprojects (can be more level of subprojects)  and its build configs via some rest api without scripting?

Up till now I was able to find all the builds (all the builds per build configuration, but I want only the latest success build per build configuration) under specific projectid via this rest:

(1)  http://HOST:PORT/app/rest/builds?locator=affectedProject:(id:PROJECT_ID)&fields=build(id,buildTypeId),start:0,count:10000

and then via scripting I retrieved the total test count for each build via this rest:

(2)  http://HOST:PORT/app/rest/testOccurrences?fields=count&locator=build:(id:BUILD_ID),start:0,count:9999

Can be these two rests combined somehow to one via some "magic" and retrieve test count for latest success builds only? Or at least reduce the first rest (1) to retrieve only the latest success builds per build configuration under specific project/subprojects?

Thanks in advance.

Regards, Gabriel.

0
1 comment

Hi Gabriel,

 

What you are looking for is not possible to do in a single request, while what you currently are doing is. You can replace the (id:BUILD_ID) with the locator bit on the builds request and you will get a response for all the builds that match the request. You can also add "status:SUCCESS" to have only the successful ones and filter a bit further.

 

Now, getting just the last successful build of an array of different configurations is probably going to be a bit more complex. Getting it for individual build configurations should be a lot easier, because you can set a much smaller count (for the build locator, not for the test locator), and only the last few builds will be displayed. Unfortunately, the "count" parameter is a bit counterintuitive in the REST API and doesn't set the count of results that should be matched, but will, from the looked up elements, limit the amount of elements that will attempt to be matched.

 

This said, the REST API is usually used via scripts or applications, and it's usually much simpler to just request the different sets of build configurations you want to go through, pick up the last build from it and then request the tests of that build as you were doing until now.

 

Hope this helps.

0

Please sign in to leave a comment.