It's all about the answers!

Ask a question

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

Lee John (51210) | asked Mar 13 '15, 5:24 a.m.
closed Mar 13 '15, 5:30 a.m. by Ralph Schoon (61.6k33643)
 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.5k6189201) | 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.
            if (ic != null)
                icm.retrieveContent(ic, os, null);
                return os.toString();
        catch (Exception e)
        return null;

Lee John selected this answer as the correct answer

Your answer

Register or to post your answer.