Export Jacoco's coverage report in XML format to Jenkins - jenkins

I have a multi-module project and I am using JaCoCo plugin to generate coverage reports. I followed this blog to create a new module(let's call it project-coverage) and then added the dependencies there and then use the report-aggregate goal of jacoco to create the aggregated report.
At the end of the build I have an XML file under project-coverage/target/site/jacoco-aggregate/jacoco.xml
How can I take this XML and export it into Jenkins? I know there is a plugin support for Jacoco in Jenkins but I am not sure how can I use this XML report and not exec files to report the coverage in Jenkins.

I know there is a plugin support for Jacoco in Jenkins but I am not sure how can I use this XML report and not exec files to report the coverage in Jenkins.
According to https://www.jacoco.org/jacoco/trunk/doc/integrations.html there are at least two plugins for Jenkins. And according to the documentation of these plugins
https://plugins.jenkins.io/jacoco/ consumes exec
https://plugins.jenkins.io/code-coverage-api/ consumes XML

Related

Testing Jenkins "Code Coverage API Plugin"

I am new to Jenkins, I have installed "Code Coverage API Plugin" in Jenkins, now want to test it.
I am trying to do steps from this page https://plugins.jenkins.io/code-coverage-api/.
But I did not understand where to put XML files from points 1 and 2.
Can anybody help me, please?
The tags present in the images are the plugins that will be added in the pom.xml of the application. By running mvn clean package cobertura will generate a report based on the formats provided, xml or html.
If the code is checked out to the job and after running "mvn clean package" cobertura report will be generated under project workspace target/site/cobertura
The xml path is provided to code coverage api to provide the graphical representation.
Jacaco is preferred for java versions >=8 whereas cobertura doesn't cover for java8 based functionalities.

MUnit coverage report of Mule in Jenkins

We are using the MUnit plugin for our code coverage of our mule application. Is there a way to integrate this plugin in Jenkins?
We searched for a MUnit plugin in Jenkins but this did not exist.
MUnit plugin for code coverage publishes the coverage in \target\munit-reports\coverage folder. You publish this report in Jenkins. But make sure you have html reports enabled in pom file.
<coverage>
<runCoverage>true</runCoverage>
<formats>
<format>console</format>
<format>html</format>
</formats>
</coverage>
Then make use of HTML Publisher Plugin and configure post build job as
Once executed you can see code coverage in project dashboard.
Hope this helps.

Generate two coverage reports in a single jenkins build

I have a Jenkins build which build all my java/angularJS project. It launch testNG tests for the java part and karma tests for the javascript part. So I can generate one testNG report (for java) and one junit report (for karma test) in my Jenkins build. This is working very well.
Until now, I used cobertura to report the coverage of my java tests. But now I would like to add also a coverage report for my karma tests (generated by Istanbul with cobertura type). The problem is that, in Jenkins, I'm allowed to generate only one coverage report in a build (I can't add more that one 'publish cobertura coverage report' post build action). So how can I have these two coverage reports in a single Jenkins build?
There's a nice plugin called HTML Publisher Plugin. You can generate HTML coverage reports and publish as much reports as you want under different titles in one Jenkins project.
For example I generate html reports using karma+istanbul and then publish them to Jenkins.
On JUnit xml report files. You should import JUnit once enumerating all files probably from different directories but you can differentiate them with proper package names inside files.
If I'm right, you can't use, as a post build action, the same plug-in twice( note that I'm not really sure). I faced this problem when I worked as Jenkins plug-in developer for a company and the solution was to use a plug-in that make the same thing.
For example: for JUnit reports there is an official JUnit plugin and also XUnit. For my problem it was simple.
So, maybe you can find a plug-in that do the same thing as Cobertura or you can change the output format of the java coverage or karma coverage. For example, for java you can use EclEmma or Jacoco...

Reusing several report files in jenkins sonar plugin

I'm generating several XML report files via ant task (checkstyle, findbugs, macker, jacoco, ncss, classycle, etc.).
I want the to reuse the generated files in jenkins sonar plugin. Is there any way to do so?
I'm planning in setting the properties in the project specific sonar-project.properties file. But I can't find any of these options at codehaus documentation site.
There's no point to reuse:
checkstyle or findbugs reports as SonarQube also executes those tools
ncss or classycle reports as it is SonarQube very job to compute those metrics
For JaCoCo, you can reuse reports if you don't want SonarQube to execute the unit tests again. See http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests+for+Java+Project.

Qunit + JSCoverage + Jenkins

I have started using Qunit to test my JS code. I am looking into JSCoverage to generate the coverage reports later. We have a CI server (Jenkins) which already do a few things with our PHP code and I was wondering if anyone can comment on how I can integrate the report from my Qunit and JSCoverage into Jenkins
Thanks
Sparsh
QUnit: use QUnit API to generate junit XML files. Here's a sample.
In Post-build Actions for your job you then check Publish JUnit test result report and specify your junit XML files (or their file pattern). Jenkins will then mark builds that have failed tests as unstable and produce a nice trend graph of successful/failing tests.
A few more details, for those actually attempting this:
Putting together QUnit and Jenkins
If you want to run QUnit and publish the results in Jenkins, you'll need to do the following:
Step 1: Getting QUnit to generate an XML file compatible with JUnit.
If you're using Apache Ant, this question explains how to get
QUnit to generate XML.
If not, you can use Grunt and
grunt-qunit-junit, together with grunt-contrib-qunit, to
run your .html tests.
And if you're not into either Ant or Grunt, here is
a script for PhantomJS to run your tests directly and produce
JUnit-style XML.
Step 2: Processing that XML file
This is the easy step - look in "Post-build Actions" for your job in Jenkins, and add the path to the XML file.

Resources