Generating code coverage and reports for all modules using Jenkins - jenkins

We have an instant app project that is instrumented using jacaco. We run these jobs and report on the coverage using the jenkins coverage reporting plugin.
Our reports only show coverage reports for the base module and not the feature modules.
How do we resolve this? Thank you!

After reviewing the jacoco plugin for Jenkins I realized I needed to add the other modules details to the various fields:
Path to exec files (e.g.: /target/.exec, **/jacoco.exec):
Example:
base/build/jacoco/*.exec, feature-1/build/jacoco/*.exec
Path to class directories (e.g.: **/target/classDir, **/classes)
Example:
base/build/intermediates/classes/debug, feature-1/build/intermediates/classes/debug

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.

Export Jacoco's coverage report in XML format to 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

Jenkins javadoc plugin doesn't generate documentation

I have installed Jenkins, create a project and configure it.
I run into a problem, Jenkins do everithing great except documentation generating.
Could anyone point me where I have done mistake, and how fix it?
Thank you.
------------------------ New information ----------
Console output:
I have renamed doc to javadoc directory, but it isn't help.
Here is screenshot of javadoc directory contents in console, it is clear that Jenkins plugin didn't generate documentation, but why?
It sounds like you are expecting the Jenkins plugin to produce the documentation. The Jenkins plugin merely copies files from the job's workspace folder to the build's archive area and provides a link to it. If your build steps don't produce Javadoc, then Jenkins won't be able to archive and provide a link to it.
Does your pom file include the maven-javadoc-plugin?
Are your build steps invoking a goal that includes Javadoc generation?
For example, "mvn jar" would compile Java and build the jar but not build the javadocs. Clearly you have executed a goal that executes the tests and provides a code coverage report, but that does not trigger the Javadoc goals either. You would need to make sure your build steps include a javadoc goal - i.e., mvn javadoc:javadoc. The standard goals can be found here: https://maven.apache.org/plugins/maven-javadoc-plugin/plugin-info.html .

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

Sonar displaying 0% Emma coverage report

I agree that this question is asked many a times by many people and many solutions are already been provided. However, after referring to umpteen links, not being able to display the Emma report in Sonar is driving me crazy. Below is a description of what I am trying to do.
My java project is a multi module maven project. We are using EMMA as the code coverage tool and Jenkins to build the project, Sonar to analyze the code and configured Sonar for our build job using the Jenkins sonar plugin. Up to this point, the story is great. The problem comes when I try to reuse the reports generated by Emma during Sonar analysis. There is no apparent error in the Sonar analysis logs during the build, however, in Sonar project dashboard the coverage report is 0%. Below is configuration data that I provide in the Sonar configuration section of my Jenkins build job.
-Dsonar.core.codeCoveragePlugin=emma
-Dsonar.emma.reportPath=/target
-Dsonar.dynamicAnalysis=reuseReports
-Dsonar.surefire.reportsPath=/target/surefire-reports
Sonar Version : 3.0
Emma plugin versions:
emma-maven-plugin : 1.0-alpha-2
Sonar Emma Plugin :1.0.1
emma : 2.0.5312
The Maven build generates the coverage.em files in the individual modules' target folder. No coverage.ec file is generated. Is it mandatory to have both coverage.ec and coverage.em files for Sonar?
The coverage.es,html,txt,xml files are generated in the project build directory/emma folder
The Sonar analysis logs for a module looks like below.
[INFO] [15:06:02.829] Sensor org.sonar.plugins.emma.EmmaSensor#bfc33...
[WARN] [15:06:02.844] Resource will be ignored in next Sonar versions, index is locked: com.mycompany.mypackage.tests.util.Activator
[INFO] [15:06:02.876] Sensor org.sonar.plugins.emma.EmmaSensor#bfc33 done: 47 ms
The above logs make me think that Sonar is indeed doing something with the generated Emma reports, but not displaying anything on the Sonar project dashboard.
Please let me know where I may be going wrong or what additional thing needs to be done to get this working.
I think this thread might me useful. http://sonar.15.n6.nabble.com/Receiving-quot-index-is-locked-quot-warning-when-Emma-sensor-runs-td4676490.html
It describes the same problem and gives you some workarounds

Resources