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

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

0 votes



5 answers

Permanent link
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)

0 votes


Permanent link
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);

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.

0 votes


Permanent link
Thank you nick, will explore the possibilities

0 votes


Permanent link
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:

0 votes


Permanent link
Sorry, I missed your Jan 27 comment.

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,947

Question asked: Jan 26 '12, 4:57 a.m.

Question was seen: 6,460 times

Last updated: Jan 26 '12, 4:57 a.m.

Confirmation Cancel Confirm