It's all about the answers!

Ask a question

How to get work item included in build result using java server API


Dastan Ali (17616) | asked Jun 18 '19, 5:16 a.m.
edited Jun 18 '19, 5:18 a.m.

How can get work item included in build result using java server API, I am looking for API from build component.

One answer



permanent link
Sridevi Sangaiah (59179) | answered Jun 19 '19, 6:19 a.m.
JAZZ DEVELOPER
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);
    }
}

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.