0

I am using jenkins pipeline for my React project to with test, build and deploy steps.

I integrated sonarqube with my project. But sonar's jacoco doesn't assess my coverage report which is in generic coverage format(test-report.xml)

Is there a way to get my report as "jacocoTestReport.xml" in my React project without using maven or gradle. I couldn't find any document or 3rd party tools?

My related pipeline script:

sh '''
   ${scannerHome}/bin/sonar-scanner \
   -Dsonar.projectKey=xxxxxxxxxxxxxx \
   -Dsonar.sources=. \
   -Dsonar.sources=. \
   -Dsonar.coverage.jacoco.xmlReportPaths=test-report.xml \
   -Dsonar.testExecutionReportPaths=test-report.xml \
   -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info \
   -Dsonar.coverageReportPaths=test-report.xml \
   -Dsonar.host.url=https://xxxxxxxxxxxxxx \
   -Dsonar.login=xxxxxxxxxx
'''

The related error is like:

: Sensor Generic Coverage Report
INFO: Parsing /var/jenkins_home/workspace/**********/test-report.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 36.948s
INFO: Final Memory: 49M/690M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Error during parsing of the generic coverage report '/var/jenkins_home/workspace/*******/test-report.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: Unknown XML node, expected "coverage" but got "testExecutions" at line 2
msahin
  • 1,520
  • 1
  • 16
  • 22

1 Answers1

0

I assume you are only building a react application, hence that it is just JavaScript/TypeScript and my answer is based on that assumption.

If that is the case you can simply ignore the sonar.coverage.jacoco.xmlReportPaths property. You are already providing that information via the lcov.info file. Sonarqube will be able to read the coverage information from this file.

Furthermore the test-report.xml normally only contains a list of the executed tests and their outcome. You will normally find no kind of coverage information in there. Therefore your build might also break on the sonar.coverageReportPaths property (my suggestion is also to remove that one).

Simon Schrottner
  • 4,146
  • 1
  • 24
  • 36