which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
SonarScanner 4.8.0.2856
SonarQube server 9.9.1.69595
jacoco 0.8.10
what are you trying to achieve
i run ‘maven clean verify’ and report task.
i want to see the code coverage in sonarqube results, produce the xml and see the output in the SQ gui
what have you tried so far to achieve this
i have set the property :
sonar.coverage.jacoco.xmlReportPaths=**/target/site/jacoco/jacoco.xml
and during the sonarqube scanner phase this is seen in the log:
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=47ms
Also when i go into the project in sonarqube i can see that the jacoco.xml file is found in the correct path (and there are correct values in there) but , still the code coverage is 0%
How can i make it so that the code coverage is shown in the GUI?
The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.
Ordinary analysis logs should be generated automatically, without the need for -X on the Maven command line. Although if you did want debug-level logging, you could easily add to your extraProperties:
From what I can see - and as you said from the start - your report is imported without errors:
2023-06-19T13:01:30.7573636Z 15:01:30.754 INFO: Sensor JaCoCo XML Report Importer [jacoco]
2023-06-19T13:01:30.7807228Z 15:01:30.770 INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
2023-06-19T13:01:30.7807627Z 15:01:30.770 DEBUG: Reading report 'F:\Agents\4\ws\118\s\jaf-guilogs\target\site\jacoco-aggregate\jacoco.xml'
2023-06-19T13:01:30.8172745Z 15:01:30.801 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=47ms
Typically in a case where the report is read by the coverage that shows up in SonarQube is below expectations, there are errors reported during the coverage report import. That’s not the case here, so you should take a look at what’s in your report:
does it include all the files you think it should?
does it show the coverage you expect for those files?
Hi, there is correct data in the .xml file as far as i can see.
but it seems it just isnt showed in the gui for the project… as it should have more than 0% coverage… im guessing there should be some other configuration in sonarqube to see that? should i change something in the general settings?
I see actually that sonarqube says/thinks its XML and not java…
1.2K lines XML so that might be the issue? how to make it see that it is java code instead of xml ?