It's all about the answers!

Ask a question

How to get changes out of build (api)

Yehiel Glass (25528786) | asked May 12 '13, 4:00 p.m.

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.


2 answers

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




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

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

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.

 The buildLinkType is:
whose value is ""

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

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:, 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 (8057140190) | 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.