Programatically modify build result
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)
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:
2. We store a IContent with this File:
3. We create a IBuildResultContribution and set its data with the IContent:
4. We add the contribution to a IBuildResult:
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.
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);
IContent content = (IContent) teamRepository.contentManager().storeContent(new FileInputStream(file), null);
3. We create a IBuildResultContribution and set its data with the IContent:
IBuildResultContribution contribution = BuildItemFactory.createBuildResultContribution();
contribution.setLabel(label);
contribution.setComponentName(componentName);
contribution.setExtendedContributionData(content);
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.
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: