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

How to get changes out of build (api)

 Hello,

How can I get (api) the new changes (list of change-sets) of a build ?
I want to change the status of all the work-items that was included in a build. 
I created a participant action at the start of a build but can't get the change-sets.

Thanks,
Yehiel

0 votes



2 answers

Permanent link
Hi Yehiel, your participant would need to run after the SCM participant.  The change sets that were accepted are not directly referenced by the build (though we do link to work items associated with those change sets).  Instead, we add a contribution to the build pointing to the SCM snapshot taken after the accept.  When you click the Changes link on a build, it's actually comparing with the snapshot from the previous (non-personal) build, and delegating to the Change Explorer / Change Summary view to show the changes.

If it's really the work items you're after, take a look at the code in: 
com.ibm.team.build.internal.client.workitem.WorkItemHelper.getIncludedWorkItems(ITeamRepository, IBuildResultHandle, IProgressMonitor)
which does a links query:

        List<IWorkItemHandle> reportedWorkItems = new ArrayList<IWorkItemHandle>();


        ILinkManager linkManager = (ILinkManager) teamRepository.getClientLibrary(ILinkManager.class);

        IReference source = linkManager.referenceFactory().createReferenceToItem(buildResultHandle);

        ILinkCollection referencesToResults = linkManager.findLinksBySource(buildLinkType, source, monitor).getAllLinksFromHereOn();


        for (Object object : referencesToResults) {

            ILink link = (ILink) object;

            IWorkItemHandle workItemHandle = (IWorkItemHandle) link.getTargetRef().resolve();

            if (workItemHandle != null) {

                reportedWorkItems.add(workItemHandle);

            }

        }


        return (IWorkItemHandle[]) reportedWorkItems.toArray(new IWorkItemHandle[reportedWorkItems.size()]);


1 vote

Comments

Not sure why the forum software is making iworkitemhandle be lower case.  It should be IWorkItemHandle, which is what I pasted.


 The buildLinkType is:

com.ibm.team.build.internal.common.links.BuildLinkTypes.INCLUDED_WORK_ITEMS
whose value is "com.ibm.team.build.linktype.includedWorkItems"

There's actually a dual representation for "included in build" work item links.  In addition to the links, we also keep them as a build result contribution, with a content blob listing the work item item ids (UUIDs).  See the code in:

com.ibm.team.build.internal.client.workitem.WorkItemHelper.getFixedInBuild(ITeamRepository, IBuildResultHandle, IProgressMonitor)
if you want to go that route.

Hi, Nick I am trying to fetch the work items included in build result in event handling follow up action, it is the server side behavior. So I can not use the code you mentioned with client API. Do you have any suggestion for server side API for ILink service to get the included work items for a build result?


Permanent link
From the other forum topic, I get the answer:

ILinkService linkService = getService(ILinkService.class);
        ILinkServiceLibrary linkLibrary = (ILinkServiceLibrary) linkService.getServiceLibrary(ILinkServiceLibrary.class);
        IReference source = linkLibrary.referenceFactory().createReferenceToItem(buildResultHandle);
        ILinkCollection referencesToResults = linkLibrary.findLinksBySource(buildLinkType, source).getAllLinksFromHereOn();

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
× 10,938

Question asked: May 12 '13, 4:00 p.m.

Question was seen: 4,827 times

Last updated: Jan 18 '16, 12:47 p.m.

Confirmation Cancel Confirm