Retrieve BuildDef properties from Build Result programmatically
Programmatically I have a query that retrieves all the buildresults for a specific type of builddefinition(getID).
I have that working. Next I want to filter the returned buildresult list based on the property value set in the BuildRequest/BuildDef. I.E. when you view a build result(details) from the UI buildresults view, a Properties tab is displayed listing all the properties from that build request/def. I want to programmaticlly get that property list so I can check for a specific value in a property so I can filter the result list (i.e. discard results that do not match the property value). I assume this can be achieved because it must be done by the UI to display the properties tab. Can you tell me how or point me to source code that already does this so I can use it as a model. I have been looking through the sdk and haven't found it yet. Thanks -Steve P.S. I think I could use IBuildResult.getBuildRequests which returns a List of IBuildRequestHandle (Y a list, shouldn't there be just one request per result?) Next use IBuildRequest. Convert the handle to a BuildRequest and use helper method Buildrequest.getBuildDefinitionProperties, which under the covers gets the buildDefinition Instance and gets the properties from the instance. Update: The List of BuildRequestHandles comes back empty for all the BuildResults; therefore, I'm still at a lost at how to get the build properties for the buildrequest/builddef for a specific build result? Here is the code I am using, which logically is similar to BuildPropertiesContributionProvider.initializeContributionProvider in getting the props from the BuildDefInstance. String[] properties = new String[] { IBuildResult.PROPERTY_LABEL }; List buildResults; buildResults = teamRepository.itemManager().fetchPartialItems( queryPage.getItemHandles(), IItemManager.DEFAULT, Arrays.asList( properties ), monitor ); for (Object result : buildResults) { IBuildResult buildResult = (IBuildResult)result; List buildRequests = buildResult.getBuildRequests(); System.out.println( buildResult.getLabel() ); for (Object handle : buildRequests) { IBuildRequest buildRequest = (IBuildRequest)teamRepository.itemManager().fetchCompleteItem( (IBuildRequestHandle)handle, IItemManager.REFRESH, monitor ); Map buildDefProperties = buildRequest.getBuildDefinitionProperties(); System.out.println( "ProcessID: " + buildDefProperties.get( ProcessID.ant_keyword ) ); } } } |
Accepted answer
Hi,
This post might answer your question https://jazz.net/forum/questions/147719/how-do-i-access-the-build-properties-programmatically Steve White selected this answer as the correct answer
Comments Thanks for the link, but that is what I am already doing. refer to code snippit in my original question. The issue that I noted is List buildRequests = buildResult.getBuildRequests(); is returning an empty List; therefore, there is no requests to get the properties from. Yet if I view the same build results from the UI the details are displayed as expected with the properties tab correctly filled. From the rtc sdk (BuildResutlPage) I can see they use the same methods too to retrieve the properties. I don't understand Y the list of requests is empty in my case.
Steve White
commented Apr 24 '15, 9:50 a.m.
I believe I need to fetch the BuildResult from the handles returned from the query
Steve White
commented Apr 27 '15, 8:35 a.m.
That was the missing piece. Once I added the fetch for the BuildResult the getBuildRequests() returned a valid list and I was able to fetch each request and filter on the properties values.
|
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.