How to download log file from build result through plain java client library
Accepted answer
code in one of my tools
ITeamBuildClient buildClient = (ITeamBuildClient) RepoServer.getClientLibrary(ITeamBuildClient.class);
// get build result
...
// use build result to get log contribution content object and data
IBuildResultContribution[] ibrcl =buildClient.getBuildResultContributions(br, IBuildResultContribution.LOG_EXTENDED_CONTRIBUTION_ID, null);
for(IBuildResultContribution ibrc : ibrcl)
{
String s=getContent(ibrc.getExtendedContributionData(), RepoServer.contentManager());
}
// worker routine to get the string from the content object
private static String getContent(IContent ic, IContentManager icm)
{
// make an output stream for the content manager
OutputStream os = new ByteArrayOutputStream();
// get the content of the content object.
try
{
if (ic != null)
{
icm.retrieveContent(ic, os, null);
return os.toString();
}
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
ITeamBuildClient buildClient = (ITeamBuildClient) RepoServer.getClientLibrary(ITeamBuildClient.class);
// get build result
...
// use build result to get log contribution content object and data
IBuildResultContribution[] ibrcl =buildClient.getBuildResultContributions(br, IBuildResultContribution.LOG_EXTENDED_CONTRIBUTION_ID, null);
for(IBuildResultContribution ibrc : ibrcl)
{
String s=getContent(ibrc.getExtendedContributionData(), RepoServer.contentManager());
}
// worker routine to get the string from the content object
private static String getContent(IContent ic, IContentManager icm)
{
// make an output stream for the content manager
OutputStream os = new ByteArrayOutputStream();
// get the content of the content object.
try
{
if (ic != null)
{
icm.retrieveContent(ic, os, null);
return os.toString();
}
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}