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
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.