It's all about the answers!

Ask a question

I can view build results using the RTC eclipse client, but not with browser com.ibm.team.build.viewResult


K M (38324348) | asked Nov 19 '13, 2:37 p.m.
retagged Dec 16 '13, 1:13 p.m. by David Lafreniere (4.5k7)
I create build results using the java api, I can view the results using the eclipse client but not with the browser
https://rtc_instance:9443/jazz/web/projects/project1#action=com.ibm.team.build.viewResult&id=_OqxDUFBfEeOzj-1HuY57ug
I get he result title but nothing else, no error is reported in the browser.

When I hover on the build result in the browser, the result's information appears.

Comments
K M commented Nov 22 '13, 12:35 p.m. | edited Nov 26 '13, 3:59 p.m.

when I use the eclipse gui, it reports the build result has no start request. Can this be the problem?

Is their any way of debuging this problem?


K M commented Nov 25 '13, 4:49 p.m. | edited Nov 26 '13, 4:00 p.m.

If I add a IBuildRequest buildRequest, I can now see most of the the build results

All except workitems associated with the results.


K M commented Nov 26 '13, 2:35 p.m. | edited Nov 26 '13, 4:00 p.m.

I add the work items to the result using

        contribution = BuildItemFactory.createBuildResultContribution();
        contribution.setExtendedContributionTypeId(WorkItemConstants.EXTENDED_DATA_TYPE_ID);
        contribution.setImpactsPrimaryResult(false);
        if ((handleIds != null) && (handleIds.length != 0)) {
            contribution.setExtendedContributionData(ContentUtil.stringArrayToContent(repo, handleIds,'\n'));
        }       
        result = buildClient.addBuildResultContribution(result, contribution,IBuildResult.PROPERTIES_COMPLETE, null);       

I do not link the work item to the build result

2 answers



permanent link
Nick Edgar (6.5k711) | answered Nov 26 '13, 3:56 p.m.
JAZZ DEVELOPER
edited Nov 26 '13, 3:59 p.m.
Hi K.  The "included in build" links have a dual representation:
(1) a contribution to the build, as you're creating in the code above
(2) item links (ILink) between the build result and work item, of type  "com.ibm.team.build.linktype.includedWorkItems"

See code in com.ibm.team.build.internal.publishing.WorkItemPublisher.tagWorkItems(IWorkItemHandle[], IBuildResult, ITeamRepository) for how (2) is done.

In the Eclipse UI, the build result gets the work items referenced from the build using (1) but in the web UI it uses (2).  The links are also needed to see the referencing build(s) from work items, which don't know about build result contributions.


Comments
K M commented Nov 26 '13, 6:39 p.m.

I did see that in one of the examples, but com.ibm.team.build.internal.publishing      does not exists in
RTC 3 java api I can not import it.

I have the same problem with com.ibm.team.build.linktype 

Is their a diffferent way, or am I missing something in the SDK


K M commented Nov 26 '13, 6:45 p.m.

I also can not find them in the java api doc


Nick Edgar commented Nov 27 '13, 10:44 a.m.
JAZZ DEVELOPER

Sorry, that code is in the com.ibm.team.build.toolkit plugin, which is in the 4.x SDK but was omitted from the 3.x SDK.  See next answer for the relevant code. 


permanent link
Nick Edgar (6.5k711) | answered Nov 27 '13, 10:45 a.m.
JAZZ DEVELOPER

Here's the code I mentioned above.


    private void tagWorkItems(IWorkItemHandle[] workItemHandles, IBuildResult buildResult,

            ITeamRepository teamRepository) throws TeamRepositoryException {


        ILinkManager linkManager = (ILinkManager) teamRepository.getClientLibrary(ILinkManager.class);

        List unlinkedWorkItems = findUnlinkedWorkItems(workItemHandles, buildResult, linkManager);

        List links = new ArrayList();


        List workItems = teamRepository.itemManager().fetchCompleteItems(unlinkedWorkItems, IItemManager.REFRESH, null);

        for (int i = 0; i < unlinkedWorkItems.size(); ++i) {

            IWorkItemHandle workItemHandle = (IWorkItemHandle) unlinkedWorkItems.get(i);

            IWorkItem workItem = (IWorkItem) workItems.get(i);

            links.add(createLink(teamRepository, workItemHandle, workItem, buildResult));

        }


        linkManager.saveLinks(links, null);

    }


     private ILink createLink(ITeamRepository teamRepository, IWorkItemHandle workItemHandle, IWorkItem workItem, IBuildResult result)

            throws TeamRepositoryException {

        IBuildDefinition definition = (IBuildDefinition) teamRepository.itemManager().fetchCompleteItem(

                result.getBuildDefinition(), IItemManager.DEFAULT, null);


        IHelperType helperType = IHelperType.IRegistry.INSTANCE.getHelperType(

                LinksPackage.eINSTANCE.getReference().getName(), LinksPackage.eNS_URI);


        String sourceComment = ItemHelper.validateStringAttributeLength(definition.getId() + " " + result.getLabel(), //$NON-NLS-1$ 

                helperType, LinksPackage.eINSTANCE.getReference_Comment().getName());


        IReference source = IReferenceFactory.INSTANCE.createReferenceToItem(result, sourceComment);


        IReference target;

        if (workItem == null) {

            // work item is missing or invisible, so create a link but provide no comment

            target = IReferenceFactory.INSTANCE.createReferenceToItem(workItemHandle);

        } else {

            String targetComment = ItemHelper.validateStringAttributeLength(

                    WorkItemTextUtilities.getWorkItemText(workItem), helperType,

                    LinksPackage.eINSTANCE.getReference_Comment().getName());

            target = IReferenceFactory.INSTANCE.createReferenceToItem(workItemHandle, targetComment);

        }


        return ILinkFactory.INSTANCE.createLink(BuildLinkTypes.INCLUDED_WORK_ITEMS, source, target);

    }



Comments
Nick Edgar commented Nov 27 '13, 10:46 a.m. | edited Nov 27 '13, 10:47 a.m.
JAZZ DEVELOPER
where BuildLinkTypes.INCLUDED_WORK_ITEMS is:

public static final String INCLUDED_WORK_ITEMS = "com.ibm.team.build.linktype.includedWorkItems"; //$NON-NLS-1$

 
A lot of the logic here has to do with shortening the comment on the work item reference if needed. If too long for the field, the save will fail.

K M commented Nov 27 '13, 1:27 p.m.

It works

just a side note if I removed a build result using the gui, it does not remove the link form the workitem
I go to the workitem and I can not remove the link using the gui

Is their no way using the gui to remove the link?


Nick Edgar commented Nov 27 '13, 1:37 p.m.
JAZZ DEVELOPER

Good to hear.  Regarding the links, no there's no way to delete them. The intent is that you may still want to know which builds a work item's change sets were included in, even if the referenced build has been deleted.

Your answer


Register or to post your answer.