How to generate a cobertura html report from an xml report

400 views
Skip to first unread message

Remi Dargent

unread,
Jan 13, 2015, 1:40:07 PM1/13/15
to jenkins...@googlegroups.com

I want to generate a cobertura html report from the cobertura xml report. It seems that Jenkins Cobertura plugin can do this but I could not figure out how. I tried the following but it does only generate parts of the html report (taken from CoberturaPublisher.java):

Set<String> sourcePaths = new HashSet<String>();
CoverageResult result = null;
try {
    result = CoberturaCoverageParser.parse(coberturaXmlReport, null, sourcePaths);
} catch (IOException e) {
    LOG.warn(format("Failed parse report %s", coberturaXmlReport.getAbsoluteFile()));
}

if (result != null) {
    result.setOwner(null);
    final FilePath paintedSourcesPath = new FilePath(new File(destinationDir)).child("html");
    paintedSourcesPath.mkdirs();
    // Get System default encoding;
    SourceEncoding encoding = SourceEncoding.getEncoding(System.getProperty("file.encoding"));
    OutputStream os = new FileOutputStream("XmlToHtml.log");
    BuildListener listener = new StreamBuildListener(os);
    SourceCodePainter painter = new SourceCodePainter(paintedSourcesPath, sourcePaths, result.getPaintedSources(), listener, encoding);
    final FilePath moduleRoot = new FilePath(new File(destinationDir));

    moduleRoot.act(painter);
}

Am I missing something?

Reply all
Reply to author
Forward
0 new messages