I downloaded a maven project from this link
Project samples are available on github that can be browsed or downloaded: projects/languages/java/code-coverage/ut
When I run "mvn clean test sonar:sonar" from the command line, I see the jacoco.exe file getting generated and shows the report in SONAR. What can I do to NOT show this code coverage report on the SONAR?
Can you please tell me the settings that I need to make?
Thanks.
I don't know your SonarQube version but I guess launching the same command with "-Dsonar.dynamicAnalysis=false" should do the job.
Related
I have a multimodule Maven project where the coverage reports are located in another module than the covered Java classes. An import of a not empty xml coverage report (with coverage information) into Sonarqube is successful but shows a coverage of 0.
Steps to reproduce:
Checkout following github project and build it with mvn clean verify. After that there exist an aggregated xml report located in coverage/target/site/jacoco-aggregate-all/jacoco.xml. You can see coverage data in there and also in the corresponding html-Report.
Start sonarqube (current version 8.4.1) with following command and wait a little bit.
docker run -d -p 9000:9000 sonarqube
edit: Plugin "JaCoco xml report importer" is already installed in this image.
Publish coverage data with following (verbose) command. Importing of report was successful (see log).
mvn sonar:sonar -X -Dsonar.projectKey=example -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=admin -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco-aggregate-all/jacoco.xml
## Log output contains
...
10:54:28.519 Reading report '<project-path>\maven-multimodule-coverage\coverage\target\site\jacoco-aggregate-all\jacoco.xml'
...
Browse to http://localhost:9000/dashboard?id=example. You see coverage of 0.
What am I doing wrong?
It turned out that it works if I use an absolute path for the xml report file. So I added
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../coverage/target/site/jacoco-aggregate-all/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
to the top maven pom so each module points to the same report file. For a deeper nesting of module directories you have to introduce a property main.basedir or something.
The main understanding is that you do not provide sonar a coverage report which get mapped to the module classes, but you provide module classes which get mapped to a coverage report.
Please install JaCoco xml report importer plugin on sonarqube instance (you will find it under marketplace just search for jacoco there). This plugin will pick up your code coverage and import it to sonarqube. so after installing plugin please use the same command to see result on sonarqube which is
mvn sonar:sonar -X -Dsonar.projectKey=example -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=admin -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco-aggregate-all/jacoco.xml
I have successfully integrated the allure-report to my Maven based testNG project, and report is successfully generated which I can see by running a jetty server and looking at my localhost. So the xml reports which are generated are inside the main project folder.
Now I am integrating the jenkins with my Test project, Now I am able to build the project from jenkins but not able to see the allure report in the Jenkins. I tried adding the allure-report plugin to my jenkins but I guess I am missing some basic config for allure-report and jenkins.
Kindly suggest if someone has got success in it.
You would have to configure the Allure-Plugin as a Post-Build action in your Jenkins job. There you can set the folder where your xml-results are generated to in your project. Normally this would be "target/allure-results".
The rest should be done by the plugin...
A dependencies report generated using the maven-project-info-reports-plugin is erroneously reporting only one project and zero transitive dependencies. However, a dependency-convergence report produces a complete list of dependencies. When running the project-info-reports:dependencies goal from the command line, either no output is being generated or the outputDirectory parameter is not working correctly (no report file is generated in the specified outputDirectory). Is there a default directory? I have only been able to produce the report with the mvn site plugin.
The only noticeable error I am getting is a series of "Artifact: XXXX has no file" errors, as reported in MPIR-251, but I'm wondering if this is a red herring and not indicative of the cause of the problem. Thoughts?
Configuration:
maven: 3.0.3
maven-site-plugin:3.1
maven-project-info-reports-plugin: 2.6
OS: Mac OS-X
As mentions at the usage page as
Maven has been configured to create the project info reports by default. There's no need to configure anything in your pom.xml to generate the project information reports.
Simply running
mvn site
If you would not to execute the site, please copy the maven-project-info-reports-plugin to the build. Please see the detail at my answer here. You may able to execute
mvn project-info-reports:dependencies
and you may see the result as your expected.
I hope this may help.
Regards,
Charlee Ch.
I have a cobertura.ser file, that got generated while integration-test and system test. Now I want to import my coverage this to sonar server.
How can I achieve this, so while executing mvn sonar:sonar the coverage should consider external coberture.ser file?
Can I do this using sonar, where i can see overall coverage obtain during all test run?
You need to set the following paramater to tell Sonar to use a pre-generated report:
sonar.dynamicAnalysis=reuseReports
Secondly Sonar doesn't read the "cobertura.ser" file. It can be configured as follows to read the generated XML report (See cobertura docs):
sonar.cobertura.reportPath=target/reports/coverage.xml
Finally, my reference for all this stuff comes from the from the Sonar wiki:
http://docs.codehaus.org/display/SONAR/Advanced+Parameters
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests
The Sonarsource tutorials are increasingly pushing JaCoCo. This appears to be an emerging standard (replacing the older defunct Emma project)
I've been working on this all day and haven't been able to find a solution, so thought i'd turn to the stackoverflow community.
I have a server setup with Jenkins (version 1.454). It's configured to perform the build with Maven (version 3.0.4). The build command is as follows:
clean clover2:setup verify clover2:aggregate clover2:clover
Jenkins has the sonar plugin installed and configured. My sonar install (version 3) is on a different server to jenkins. After the build is completed, i can see the results on sonar (the basics of the build).
I have installed to sonar the clover plugin (sonar-clover-plugin-2.8.jar) manually by putting it into the 'extentions/plugins' folder. It appeared in sonar and I can configure it. I put in the license, version (3.1.4) and sonar.clover.reportPath as "target\site\clover\clover.xml".
When I run the build, it is successful as before, and I can see the basic results as before in Sonar, however, I cannot see any test code coverage results.
When I look at the maven build output I notice the following:
[INFO] Writing report to '/opt/jenkins/jobs/foo/workspace/target/site/clover/clover.xml'
and then near the bottom of the output:
[INFO] [15:08:36.586] Clover XML report not found
The following are also in my pom:
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.clover.reportPath>target\site\clover\clover.xml</sonar.clover.reportPath>
<sonar.surefire.reportsPath>target\surefire-reports</sonar.surefire.reportsPath>
<sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
<sonar.clover.version>${clover.version}</sonar.clover.version>
When I look on the jenkins box, I can see that it has generated the clover.xml file (infact in my fiddling I have the clover plugin working on jenkins, so i can see the results there!).
I'm guessing at this stage that there is some issue with jenkins and sonar being on seperate boxes.
Any help would be appreciated!
Cheers.
After a lot more fiddling around, it appeared that I needed to change the following:
<sonar.clover.reportPath>${project.build.directory}/site/clover/clover.xml</sonar.clover.reportPath>
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
A good reference was the following:
all about pom variables