It's all about the answers!

Ask a question

How to download log file from build result through plain java client library


Lee John (51310) | asked Mar 13 '15, 5:24 a.m.
closed Mar 13 '15, 5:30 a.m. by Ralph Schoon (63.1k33646)
 As title, when I have a IBuildResult implemented object through querying, how do I download the log file from it?

 

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Mar 13 '15, 8:05 a.m.
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;
    }


Lee John selected this answer as the correct answer

Your answer


Register or 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.