Obtaining all Build Results from Build Definition
![]()
I've been trying two different ways to get all the build results for a build definition.
First method: I currently have code that will iterate through the repository and return every single build definition. Is there a way to access all the build results from these build definitions? Second method: I followed the example on https://jazz.net/wiki/bin/view/Main/BuildJavaProgrammingExamples, and currently am able to get all the build results from the respository, sorted by their build times. Unfortunately, this means that the build results can be from any of the build definitions. I've tried to do: IBuildResult buildResult = (IBuildResult) result; IBuildDefinitionHandle buildDefinition = buildResult.getBuildDefinition(); I have tested the buildResult and it contains the data. However, this IBuildDefinitionHandle that is returned is null. I've checked it using the debugger as well as trying: UUID buildId= buildDefinition.getItemId(); System.out.println(buildId.toString()); Essentially what I'm trying to do is to compile a list of all the build definitions with their respective build results. If I'm able to iterate through each build definition for the build results that's great. Otherwise, just grabbing every build result and then sorting them myself based on build definition will work as well. Thanks. |
2 answers
![]()
Hi Eric,
To query the build results for a given build definition, add a filter to the query like:
Then when you run the query, pass the build definition handle:
For the 2nd issue, of getting null back for the build definition, that's happening because the example specifies that only the label property be fetched for the resulting items. Try changing the properties passed to fetchPartialItems to:
Though you won't need to fetch the definition property if you change the query to filter by definition. I suggest querying by definition rather than getting all results then grouping by definition, as the query for all results may be very large, and the longer you take to process a query, the greater the risk that the cached query results gets flushed from the server (this is only an issue if the query results span multiple pages). The example also skips an important aspect: you need to page over the results if there's more than one page. In the call to queryItems, it specifies the maximum allowable page size, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, which is 512. If there are more than these many results, there will be multiple pages. You can check if you need to iterate using:
Regards, Nick Edgar RTC Build component lead |
![]()
Hi Nick,
Thanks for putting the time in making your response. I haven't gotten a chance yet to implement this, but I know you've saved me a lot of time and frustration! |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.