For all our jobs that define the paths to the Cobertura reports via sonar.flex.cobertura.reportPaths, we’ve noticed that during analysis the Sonar Scanner will default back to using the target/site/coverage.xml path value:
For example in the Jenkins job config we’ve defined this in the Analysis Parameters field:
But during the Sonar Analysis this value is ignored and the default value is used
INFO: Sensor CoberturaSensor [cobertura]
WARN: Cobertura report not found at /var/lib/jenkins/jobs/BlackCatMaster-Sonar/workspace/target/site/cobertura/coverage.xml
INFO: Sensor CoberturaSensor [cobertura] (done) | time=0ms
The full path it should be looking for is: /var/lib/jenkins/jobs/BlackCatMaster-Sonar/workspace/blackcat/blackcat-core/target/site/cobertura/coverage.xml
I did find an old sonar-project.properties file in the project repo that’s a few years old. The sonar.flex.cobertura.reportPaths property was not defined in the file. I removed the file from the repo and rebuilt but still seeing the same functionality.
I actually think it’s coming from the sonar-cobertura-plugin-2.0.
To test I uninstalled the Cobertura plugin from Sonar. Then rebuilt the Jenkins job and no longer see CoberturaSensor being called in the output, however still don’t have coverage % metrics on the sonar project page.
Interestingly I reinstalled the Cobertura plugin, then added a step in the Jenkins job to copy the coverage.xml from our path to the “default” one specified in the warning and now see Coverage % metrics on the Sonar project page, also see this in the Sonar Scanner output:
So that’s a workaround for our projects that generate a single coverage report. However this won’t work for some of our jobs that generate multiple coverage.xml’s.
Indeed, I didn’t see that the logs you gave us in the first message were not issues by the Flex analyzer.
If you have multiple report files, I suggest that you use sonar.flex.cobertura.reportPaths instead of sonar.cobertura.reportPath. If it doesn’t give you the expected result, check the logs and see if you can find something like:
I actually don’t see the Flex Analyzer Sensor being called in the output. We have sonar.flex.cobertura.reportPaths set, is there any other required properties that need to be set in order to have the Flex Sensor called?
There’s no file in your project which is considered as a Flex source file
If you run the analysis in debug mode, do you see something like the following?
DEBUG: Declared extensions of language Flex were converted to sonar.lang.patterns.flex : **/*.as
...
DEBUG: 'Flex' skipped because there is no related file in current project
DEBUG: 'Flex Cobertura' skipped because there is no related file in current project
That’s the issue, the Cobertura coverage xmls are generated from Java source code, not Flex. Searched this doc for Cobertura and only saw the Flex and Python options: Test coverage overview
Which Sonar property should be used to specify multiple cobertura coverage.xml report paths for Java?
Instead of running the SonarQube Scanner post-build step, I ended up integrating Sonar analysis into the Maven build step by adding “sonar:sonar” to the maven goals and options field (after setting the global settings mentioned in the SonarScanner for Maven doc), all the cobertura coverage.xmls are now automatically discovered.
I don’t think that there’s a way to specify multiple Cobertura report paths for Java.
As far as I know, the only option to import Cobertura reports for Java is to use sonar-cobertura and it seems to accept only a single report specified through sonar.cobertura.reportPath.