How to get work item included in build result using java server API
One answer
We use the code below to get the list of included work items:
IBuildResultHandle buildResultHandle = ...
List<IWorkItemHandle> includedWorkItems = new ArrayList<IWorkItemHandle>();
ILinkManager linkManager = (ILinkManager) teamRepository.getClientLibrary(ILinkManager.class);
IReference source = linkManager.referenceFactory().createReferenceToItem(buildResultHandle);
ILinkCollection referencesToResults = linkManager.findLinksBySource(BuildLinkTypes.INCLUDED_WORK_ITEMS, source, monitor).getAllLinksFromHereOn();
for (Object object : referencesToResults) {
ILink link = (ILink) object;
IWorkItemHandle workItemHandle = (IWorkItemHandle) link.getTargetRef().resolve();
if (workItemHandle != null) {
includedWorkItems.add(workItemHandle);
}
}