It's all about the answers!

Ask a question

Programatically modify build result

Karthik Krishnan (8825115162) | asked Jan 26 '12, 4:57 a.m.

Is it possible to modify build result via Plain JAVA API?

I am looking to add Files to build result nightly. Is this possible?



5 answers

permanent link
Nick Edgar (6.5k711) | answered Jan 26 '12, 11:03 a.m.
Yes, from the client side you can use:, IBuildResultContribution, IProgressMonitor)
where the client interface is obtained using:

Upload the IContent content blob first, then set it as the contribution's data:

Other properties like the file name and size can be set as properties on the contribution.

The contribution object can be created using:

For details, I suggest looking at the source for the artifactFilePublisher and logPublisher Ant tasks:

In particular, they both go through:, ITeamRepository), File, ITeamRepository)

permanent link
SEC Servizi (97123458) | answered Jan 27 '12, 6:09 a.m.
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(); 


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.


permanent link
Karthik Krishnan (8825115162) | answered Jan 30 '12, 9:39 a.m.
Thank you nick, will explore the possibilities

permanent link
SEC Servizi (97123458) | answered Feb 03 '12, 11:10 a.m.
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: :wink:

permanent link
Nick Edgar (6.5k711) | answered Feb 03 '12, 11:38 a.m.
Sorry, I missed your Jan 27 comment.

Your answer

Register or to post your answer.