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

How to get Associated Release with a build result using java api

How do you get this when you have IBuildResult tmp_result

0 votes



5 answers

Permanent link
you have to go the other way...   the IDeliverable object represents the release, and the Artifact attribute of that object points to the associated IBuildResult.

I haven't done it, but I assume you can use the Query model to search for IDeliverable objects and maybe filter on Artifact = specific BuildResult.

see one of my query samples

https://jazz.net/forum/questions/150094/determining-build-definitions-associated-with-a-specific-project-area
search for "answered May 04 '14, 5:25 p.m. " in that topic


0 votes

Comments

for build results and build defs this is used

ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;

which client and which model is used for Deliverables?


Permanent link
see the first answer here
https://jazz.net/forum/questions/14122/enumerating-through-releases-defined-in-a-project-area

0 votes

Comments

the example uses workitem client to query all deliverables in a project then
loops to find the one I want

is their no client and model that can be used so I can query and filter like I do for build results?




Permanent link
I did not find one, but I didn't look thru the SDK source too hard.

0 votes


Permanent link
    public IBuildResult queryForBuildUsingLastModifiedTime(Timestamp lastModified) throws TeamRepositoryException {        
        ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
        IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;
        IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel);
        IBuildResult result = null;
        
        // Create query filter, Last Modified and tags not eq ""
        query.filter(buildResultQueryModel.modified()._gtOrEq(query.newDateTimeArg())._and(buildResultQueryModel.tags()._notEq(query.newStringArg())));
        query.orderByDsc(buildResultQueryModel.buildStartTime());
        Object[] parameters = new Object[] { lastModified,"" };
        
        // Run query and return results
        IItemQueryPage queryPage = buildClient.queryItems(query,parameters, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, MONITOR);
        
        int i = 0;
        while (i < queryPage.getSize()) {            
            IWorkItemClient workItemClient = ((IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class));
            IBuildResult tmp_result = (IBuildResult) repo.itemManager().fetchCompleteItems(queryPage.getItemHandles(), IItemManager.DEFAULT, MONITOR).get(i);

            // Create profile
            ItemProfile<IDeliverable> profile = ItemProfile.<IDeliverable> createProfile(IDeliverable.ITEM_TYPE,
                    AuditablesHelper.AUDITABLE_SMALL_PROFILE).createExtension(
                    Arrays.asList(new String[] {IDeliverable.NAME_PROPERTY, IDeliverable.DESCRIPTION_PROPERTY,
                            IDeliverable.PROJECT_AREA_PROPERTY}));

            
            //IDeliverable
            List<IDeliverable> deliverables = workItemClient.findDeliverablesByArtifact(tmp_result, profile,MONITOR);
            for (int x = 0; x < deliverables.size(); x++) {
                System.out.println("deliverable: " + deliverables.get(x).getName());
                System.out.println("deliverable: " + deliverables.get(x).getItemId().getUuidValue());
            }
            
            System.out.println("label: " + tmp_result.getLabel());
            System.out.println("last modified: " + tmp_result.modified().toString()  );
            System.out.println("start time: " + Long.toString(tmp_result.getBuildStartTime()));
            System.out.println("tags: " + tmp_result.getTags());
            System.out.println("uuid: " + tmp_result.getItemId().getUuidValue());
            i++;
        }
        return result;
    }

0 votes


Permanent link
Very cool!... thanks for posting back..

I would move
          IWorkItemClient workItemClient = ((IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class

outside the loop.. as you don't need to get the function entrypoint over and over..

(saves cpu cycles)

0 votes

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

Question asked: Apr 02 '15, 2:41 p.m.

Question was seen: 3,179 times

Last updated: Apr 06 '15, 1:33 p.m.

Confirmation Cancel Confirm