Programatically modify build result
Hi,
Is it possible to modify build result via Plain JAVA API? I am looking to add Files to build result nightly. Is this possible? Thanks Karthik |
5 answers
Yes, from the client side you can use:
com.ibm.team.build.client.ITeamBuildClient.addBuildResultContribution(IBuildResultHandle, IBuildResultContribution, IProgressMonitor) where the client interface is obtained using: com.ibm.team.build.client.ClientFactory.getTeamBuildClient(ITeamRepository) Upload the IContent content blob first, then set it as the contribution's data: com.ibm.team.build.common.model.IBuildResultContribution.setExtendedContributionData(IContent) Other properties like the file name and size can be set as properties on the contribution. The contribution object can be created using: com.ibm.team.build.common.BuildItemFactory.createBuildResultContribution() For details, I suggest looking at the source for the artifactFilePublisher and logPublisher Ant tasks: com.ibm.team.build.ant.task.ArtifactFilePublisherTask com.ibm.team.build.ant.task.LogPublisherTask In particular, they both go through: com.ibm.team.build.internal.publishing.AbstractFilePublisher.initializeContribution(IBuildResultContribution, ITeamRepository) com.ibm.team.build.internal.publishing.ContentPublisher.getFileContent(ITeamRepository) com.ibm.team.build.internal.publishing.ContentPublisher.storeTextContent(String, File, ITeamRepository) |
Hi Nick,
we have a file we want to add to build results from the client side. 1. We create the Java instance for the file: File file = new File("C:/foo.txt"); 2. We store a IContent with this File: ITeamRepository teamRepository = (ITeamRepository) repo.getClientLibrary(ITeamRepository.class); 3. We create a IBuildResultContribution and set its data with the IContent: IBuildResultContribution contribution = BuildItemFactory.createBuildResultContribution(); 4. We add the contribution to a IBuildResult: buildClient.addBuildResultContribution(buildResult, contribution, null); The steps seem correct to us, but the method storeContent(InputStream, IPorgressMonitor) is depreceted. Neither we can find the storeTextContent(String, File, ITeamRepository) method you mention from a IContentManager instance. We have to use the internal classes? Any help will be appreciated. Cheers. |
Thank you nick, will explore the possibilities
|
the method storeContent(InputStream, IPorgressMonitor) is depreceted. The correct method to store a IContent seems to be: IContent content = teamRepository.contentManager().storeContent(IContent.CONTENT_TYPE_UNKNOWN, null, LineDelimiter.LINE_DELIMITER_NONE, new FileInputStream(file), null, null); We found it in another post from Nick: https://jazz.net/forums/viewtopic.php?p=64327#64327 :wink: |
Sorry, I missed your Jan 27 comment.
|
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.