Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?

0 votes

Comments

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.

Thanks Ralph,

But I cannot see how get the buildResults out of the buildDefinition.
The association is only from BuildResult to BuildDefinition and not the opposite
build data model from the SDK


Accepted answer

Permanent link
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;
        }
    }
Moti Wertheimer selected this answer as the correct answer

1 vote

Comments
I used it to get the list of all builds in dsc order, iterating it lets me find the previous build.

Thanks,
Moti

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941
× 562

Question asked: Jun 13 '13, 5:12 a.m.

Question was seen: 3,989 times

Last updated: Jun 18 '13, 6:09 a.m.

Confirmation Cancel Confirm