How to get previous buildResults
Hi,
Using Java client I can get IBuildResult instance using the Query model.
Now I want to get the build before this build.
I see a way to do it using IBuildResultStatusTrend::getPreviousBuilds
But I have no access to this class using the Client (If I am not wrong).
Is there a way to get the previous builds out of a given build?
Using Java client I can get IBuildResult instance using the Query model.
Now I want to get the build before this build.
I see a way to do it using IBuildResultStatusTrend::getPreviousBuilds
But I have no access to this class using the Client (If I am not wrong).
Is there a way to get the previous builds out of a given build?
Accepted answer
Regarding Moti's comment above about getting the build results out of the build definition: It is possible to get the build results from the build definition. I'm including a method below that queries for a specific build using a label and build definition, but you could pull out the code related to the label:
public IBuildResult queryForBuildUsingLabelAndBuildDefinition(String label, String buildDefinitionId, ITeamRepository teamRepository) throws TeamRepositoryException { IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;
IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel); query.filter( query.and(buildResultQueryModel.label()._like(query.newStringArg()), buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg())));
query.orderByDsc(buildResultQueryModel.buildStartTime());
IProgressMonitor monitor = new NullProgressMonitor();
ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition buildDefinition = buildClient.getBuildDefinition(buildDefinitionId, monitor);
Object[] parameters = new Object[] { label, buildDefinition };
IItemQueryPage queryPage = buildClient.queryItems(query, parameters, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, monitor); if (queryPage.getSize() == 1) { return (IBuildResult) teamRepository.itemManager().fetchCompleteItems(queryPage.getItemHandles(), IItemManager.DEFAULT, monitor).get(0);
}
else {
return null;
}
}
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jun 13 '13, 11:26 a.m.Not sure if that will help, but I think you should be able to get the build definition and thenĀ all the build results for it. I would try that.
Moti Wertheimer
JAZZ DEVELOPER Jun 16 '13, 9:38 a.m.Thanks Ralph,