It's all about the answers!

Ask a question

RTC Plain Java API - Find BuildResult id based on ChangeSet id or WorkItem id

Annie Steenson (1324) | asked May 04 '17, 4:35 p.m.
edited May 04 '17, 5:14 p.m.

I'm using the RTC's Plain Java API.

In my program, I have a list of WorkItems and their associated ChangeSets.

I need to check if each ChangeSet was successfully built.

Each ChangeSet can be found in multiple BuildResults.

Is there a way to query for the associated BuildResults (and retrieve their ids) based on WorkItem Id or (preferably) ChangeSet Id?

In the web version of RTC, I can view "Included in Builds" for each work Item. How can I grab that list using the Plain Java API?

Accepted answer

permanent link
Ralph Schoon (63.1k33646) | answered May 05 '17, 2:11 a.m.
That is likely not trivial. 

You could look into the Locate Change Set (Search>Jazz Source control) implementation in the RTC Eclipse Client using the SDK, to try to find out how it could be done.

The Included in builds is just another link type. See for the link API. also has examples for how to use link aPI.

Annie Steenson selected this answer as the correct answer

Annie Steenson commented May 09 '17, 5:57 a.m.

Hi Ralph,

How can I grab the links attached to a BuildResult?

I'm not able to use

// get all references from the work item workingcopy
IWorkItemReferences references = workingCopy.getReferences();


IWorkItemCommon common= (IWorkItemCommon) ((ITeamRepository)workItem.getOrigin()).getClientLibrary(IWorkItemCommon.class); IWorkItemReferences references = common.resolveWorkItemReferences(workItem, null);

IItem buildResultWorkingCopy = buildResult.getWorkingCopy();


(buildResultWorkingCopy instanceof IWorkItem) returns false.

I need to be able to grab the URI References to corresponding Jenkins build.
I also need to be able to grab the WorkItem References to the ChangeSets found in the BuildResult

Ralph Schoon commented May 09 '17, 6:24 a.m.

Please look into the last link I posted in my answer, download and look at the code. 

If you have additional needs for that API, look into the links at the end of the blog post. 

The key here is IBuildResultContribution

Ralph Schoon commented May 09 '17, 6:46 a.m. | edited May 09 '17, 6:49 a.m.

Please note that the IBuildResultContributions only contain URLs that are stored in the build result. The work items and change sets that you see in the build result editor for a build result of public builds are calculated using the SCM snapshot/baseline. 

One other answer

permanent link
Ahmed Omair (41134) | answered Dec 10 '18, 7:39 a.m.

Just to record solution for getting work item from buildResult use WorkItemHelper static method getFixedInBuild.

IWorkItemHandle[] workItemHandles = WorkItemHelper.getFixedInBuild(teamRepository, buildResult, monitor);

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.