It's all about the answers!

Ask a question

Adding work items to build result using API

Morten Madsen (3053148) | asked Jun 21 '13, 7:51 a.m.
Hi, I just used these code examples to programatically populate a build result, but using the Java client API (used the ILinkManager instead of ILinkServiceLibrary as used in the referred examples).

My build result gets links to: changes, snapshot & workspace,

The work items gets a nice link "Included in builds" but my build result does not show the work items as "included in build".

Any ideas why this happens? Is there another way you should add work items to a build result?

Any ideas / thoughts?

Thanks a lot!

Accepted answer

permanent link
Nick Edgar (6.5k711) | answered Jul 17 '13, 11:23 a.m.
edited Jul 17 '13, 11:26 a.m.
Hi Morten, sorry for the delay in responding.  The issue is that "included in build" links have a dual representation: as a link like what you're creating, but also as a contribution to the build (build results have an open ended model for contributions; in this case it's represented as a contribution with a content blob containing the work item UUIDs).

It's the presence/absence of build result contributions that drives whether the corresponding summary info / tab shows up in the build result (in the UI implementation, contribution summary/page extensions list their contribution types of interest; running a links query to see if the contribution should show would be more expensive).

The contribution is added internally in, IBuildResultHandle, IWorkItemHandle[])

The main part of the source is:

        String[] handleIds = new String[workItemHandles.length];

        for (int i = 0; i < workItemHandles.length; i++) {

            handleIds[i] = workItemHandles[i].getItemId().getUuidValue();


        IBuildResultContribution contribution = BuildItemFactory.createBuildResultContribution();


        contribution.setExtendedContributionData(ContentUtil.stringArrayToContent(teamRepository, handleIds,


        return ClientFactory.getTeamBuildClient(teamRepository).addBuildResultContribution(buildResultHandle,

                contribution, IBuildResult.PROPERTIES_COMPLETE, null);

Morten Madsen selected this answer as the correct answer

Morten Madsen commented Jul 18 '13, 11:59 a.m.

NICE NICE NICE!!! :-D. If this works, I'm totally gonna give you a medal :-D. I'll report back when I've tried this out. It seems very much like the code I'm using for adding workspace and snapshot contributions, so I cannot see why it should not work!


Morten Madsen commented Jul 22 '13, 9:58 a.m.

One question, do you know what the EXTENDED_DATA_DELIMITER is?

Morten Madsen commented Jul 22 '13, 11:52 a.m.

I found that it was char '\n'. But if you can supply the place where I can get this constant, it would really help me.

Though it looks like this is an internal constant in your class seeing it lacks any qualified name.

Your answer

Register or to post your answer.