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:// .
// 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? |
2 answers
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}, 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); } }} |
Ralph Schoon (63.1k●3●36●46)
| answered Apr 06 '17, 2:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER 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); Comments
Karthik Krishnan
commented Apr 06 '17, 10:28 a.m.
Thanks Ralph for the update. I read the blog and the source code.
Ralph Schoon
commented Apr 06 '17, 10:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.
Karthik Krishnan
commented Apr 06 '17, 10:58 a.m.
I've added my comment as answer as it crosses the limit.
|
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.