Use Cobertura Coverage Report for Sonarcloud

CI: Azure DevOps

We have a Sonarcloud project that analyzes our React Project. Everything works just fine except for the Code coverage, because during the task SonarCloudAnalyze@1 the JaCoCo XML Report Importer can not find a coverageReport.
We already create a Cobertura Coverage Report, which is created and shown in the Azure Pipeline Code Coverage Tab.
However I have not found a way to use the cobertura-coverage.xml file as the source for the reportPath of the Sonarcloud, since the only Cobertura reportPath Variables seem to be for Flex and Python.

What I have tried:
Set the extraProperties Variable in SonarcloudPrepare to different reportPaths (generic, jacoco…):

 task: SonarCloudPrepare@1

        inputs:

          SonarCloud: 'SonarCloud'

          organization: 'orga'

          scannerMode: 'CLI'

          configMode: 'manual'

          cliProjectKey: 'project'

          cliSources: './src'

          extraProperties: |

                sonar.coverage.jacoco.xmlReportPaths='./coverage/cobertura-coverage.xml'

                sonar.verbose=true

Which obviously does not work and leads to the output:

Log Error

So question Nr. 1 would be: Is there a way to use that Cobertura Coverage Report for Sonarcloud or do I have to produce two different reports?
2. If I have to produce two different reports, how do I create the Jacoco Report, since all I have found is creating Jacoco reports with Maven projects, but not React apps?

Any help is appreciated!

Hey there.

Passing a Cobertura report to sonar.coverage.jacoco.xmlReportPaths is going to inevitably fail as the JaCoCo sensor will expect a very specifically formated report (a file produced by JaCoCo). This is the same for generic coverage, etc.

As the documentation notes, the expected format for code coverage on JavaScript/TypeScript is ‘lcov’

JavaScript/TypeScript

sonar.javascript.lcov.reportPaths

Comma-delimited list of paths to LCOV coverage report files. Paths may be absolute or relative to the project root.

You’ll need to make sure that a file is produced in this format by your coverage reporter to be imported into SonarCloud. Your test coverage reporter (Istanbul, Jest, etc.) should be able to handle this easily.