It's all about the answers!

Ask a question

How to get changes out of build (api)


Yehiel Glass (25538986) | asked May 12 '13, 4:00 p.m.
 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

2 answers



permanent link
Nick Edgar (6.5k711) | answered May 14 '13, 12:39 p.m.
JAZZ DEVELOPER
edited May 14 '13, 12:40 p.m.
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()]);



Comments
Nick Edgar commented May 14 '13, 12:42 p.m.
JAZZ DEVELOPER

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



Nick Edgar commented May 14 '13, 12:43 p.m.
JAZZ DEVELOPER

 The buildLinkType is:

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


Nick Edgar commented May 14 '13, 12:46 p.m. | edited May 14 '13, 12:46 p.m.
JAZZ DEVELOPER

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.


Jia Jia Li commented Jan 18 '16, 12:22 a.m. | edited Jan 18 '16, 12:47 p.m.

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
Jia Jia Li (8057152192) | answered Jan 18 '16, 12:59 a.m.
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();

Your answer


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