We have setup our project do Code Coverage with Coco.
This produces an xml file which we import in the SonarCloud run.
In SonarCube Cloud, this sometimes gives us the coverage information, but the next builds do not, coverage (total) is at zero again.
The SonarCloudAnalyze has the same output in both cases, also the XML files are the same, but the results just don’t seem to be imported in SonarQube Cloud.
Other (smaller) projects seem to be handled fine and coverage information in being presented (all using the same yml template for producing code coverage xml and doing the SonarQube tasks)
The log of the analyze if very limited, but the same in both cases:
Sensor CFamily [cpp] (done) | time=233973ms
02:14:20.878 INFO ------------- Run sensors on project
02:14:21.006 INFO Sensor cobertura [cpp]
02:14:21.116 INFO Parsing C:\a\2\s\coverage_all_unittests.xml
02:14:21.545 INFO Sensor cobertura [cpp] (done) | time=539ms
02:14:21.545 INFO Sensor Zero Coverage Sensor
02:14:22.011 INFO Sensor Zero Coverage Sensor (done) | time=465ms
Is there a way to get more information on why the results are not shown in SonarQube?
Thank you very much, looking forward to the results with this option.
We have not had many builds yet (it’s a big build, taking couple of hours). Until now the 1st 2 builds did produce results, last 2 did not.
I just added the option and will check the results. Hopefully I can get more information now that the verbose level has been changed.
Will update once I have more information
Thank you
Using the DEBUG level, I think I discoved why the coverage is sometimes zero.
We run the Code Coverage and the SonarCloud analysis in 2 different jobs, on 2 different agents.
Since the xml contains the full path to the folder, the folder from the CodeCoverage agent can be /a/2/s, where the analyze step is running in C:/a/1/s, causing the relevant files cannot be found.
I did try removing some file path elements using cmedit, but so far that does not seem to get me to the right folder depth, then it cannot resolve any file.
The xml also contains the <package name=“/a/2/s/project_name” and filename=“/a/2/sproject_name”
In the SonarCloudPrepare task, we set the sources parameter:
cliSources: project_name/src
I don’t know how to set these paths to be relative?
I’ll admit this is an area where I’m a little rusty. However, I believe the key is that the files referenced in your Cobertura report (specifically the attribute filename, everything else is ignored when resolving the file) need to be relative to the value of sonar.projectBaseDir.
You can find out how this value is currently set (probably by default) by looking in your analysis logs:
16:03:48.451 INFO: Base dir: /Users/colin/source/coberturatest/src