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

How to update the artifact URL in build results programatically?

We store the RTC build output in network File share. Unfortunately the exiting url works only in Internet Explorer as the link always has file:// .
I want to update the exiting buildResultContribution links from file:// to file:///// to make it work across all clients.

I am writing a Java application to do this and while doing so, when I use the below code it adds a new entry instead of updating the existing.

// newURL contains the changed url pattern - file:// to file://///
buildResultContribution.setExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_URL, newURL);
buildClient.addBuildResultContribution((IBuildResultHandle)buildResultWorkingCopy.getItemHandle() , buildResultContribution, null);
buildClient.save(buildResultWorkingCopy, null);


How can I save an existing instead of creating new?

0 votes



2 answers

Permanent link

 Some of that API is explained in https://rsjazz.wordpress.com/2015/10/28/build-artifacts-publishing-and-automated-build-output-management-using-the-plain-java-client-libraries/ and the linked articles. From the example build output manager:

        String theURL = publishToIRAM(aBuildOutputCandidate);
        IBuildResultContribution link = BuildItemFactory
                .createBuildResultContribution();
        // Optional set a category
        // link.setComponentName("Build Output Backup for Audits");
        link.setLabel("Download Artifact from Asset Manager");
        link
                .setExtendedContributionTypeId(IBuildResultContribution.LINK_EXTENDED_CONTRIBUTION_ID);
        link.setExtendedContributionProperty(
                IBuildResultContribution.PROPERTY_NAME_URL, theURL);
        ITeamBuildClient buildClient = (ITeamBuildClient) aTeamRepository
                .getClientLibrary(ITeamBuildClient.class);
        buildClient.addBuildResultContribution((IBuildResultHandle) buildResult
                .getItemHandle(), link, null);

0 votes

Comments

Thanks Ralph for the update. I read the blog and the source code.

I found no way to update the existing Artifact link. The code which I posted adds a new entry.
 
I downloaded the SDK now. I will look for some pointers there.

You are correct, I think that is contributing a new link and not updating it. Have you considered to find the contribution and then the link in it and change that? Just a thought.

I've added my comment as answer as it crosses the limit.


Permanent link

I am actually doing that. Below is the piece of my code. I am trying to update in the context of the current BuildResultContribution.

IBuildResultContribution[] buildResultContributionArr = buildClient.getBuildResultContributions(
                        buildResultWorkingCopy, new String[] { IBuildResultContribution.ARTIFACT_EXTENDED_CONTRIBUTION_ID},
                       rtcManager.getProgressMonitor());
for (IBuildResultContribution brArtifactLink : buildResultContributionArr)
{
    String fileURL = brArtifactLink.getExtendedContributionProperty(IBuildResultContribution.PROPERTY_NAME_URL);
    String newURL="";    
    if (fileURL!=null)
    {
        if(fileURL.contains("file://"))
        {
            newURL=fileURL.replaceAll("file://", "file://///");
            //brArtifactLink.setExtendedContributionTypeId(brArtifactLink.getExtendedContributionTypeId());
            brArtifactLink.setExtendedContributionProperty(fileURL, newURL);
            //brArtifactLink.setExtendedContributionData
            buildClient.addBuildResultContribution((IBuildResultHandle)buildResultWorkingCopy.getItemHandle() , brArtifactLink, null);
            //buildClient.save(buildResultWorkingCopy, null);
        }
    }
}

0 votes

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,938
× 562
× 89

Question asked: Apr 05 '17, 11:21 a.m.

Question was seen: 3,128 times

Last updated: Apr 06 '17, 11:25 p.m.

Confirmation Cancel Confirm