How to get changes out of build (api)
2 answers
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
Not sure why the forum software is making iworkitemhandle be lower case. It should be IWorkItemHandle, which is what I pasted.
The buildLinkType is:
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:
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?
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();