Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Adding work items to build result using API

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!
/Morten

0 votes


Accepted answer

Permanent link
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 
com.ibm.team.build.internal.client.workitem.WorkItemHelper.setFixedInBuild(ITeamRepository, 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.setExtendedContributionTypeId(WorkItemConstants.EXTENDED_DATA_TYPE_ID);

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

                EXTENDED_DATA_DELIMITER));

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

                contribution, IBuildResult.PROPERTIES_COMPLETE, null);

Morten Madsen selected this answer as the correct answer

1 vote

Comments

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!

Thanks!

One question, do you know what the EXTENDED_DATA_DELIMITER is?

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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937
× 562
× 411
× 63

Question asked: Jun 21 '13, 7:51 a.m.

Question was seen: 5,994 times

Last updated: Jul 22 '13, 11:52 a.m.

Confirmation Cancel Confirm