I’m very new to SonarQube and I’ve no experience working on SonarQube application.
In our organization, we are using SonarQube for code quality checks and etc.
I have one project which is already configured with our organization’s SonarQube and I’ve given one task to unit test my application. I’ve unit tested my application and generated the coverage report using an npm package called jest-sonar-reporter
My project is built using React and Django and the project’s structure kinda looks like this.
So now how can I tell SonarQube to pick the sonarqube-codecoverage-report.xml coverage report which is in ReactDirectory/sonarTestResults/sonarqube-codecoverage-report.xml and show the appropriate metrics result for code coverage for the project in the SonarQube dashboard?
You’ll need to pass the path-from-project-root as the argument to the correct analysis parameter. The docs on the scanner you’re using should tell you how.
This is one stage in Jenkinsfile. in this, I’ve added like sonar.sonar.javascript.lcov.reportPaths=<path to report>
So the path should be the relative or absolute path? I’ve given the relative path and the coverage file is not detecting I feel because in the SonarQube dashboard coverage % is still 0.
Your <path to report> is typically going to be relative to project root (which is presumably where analysis is running from). What to share the relevant log lines where it’s not finding your report?
sorry for the delayed response! Our organization had not given admin privileges to the project. So once that getting done I’m able to see the administration tab and could relate to what you were trying to say.
You can add this to your analysis parameters (in your Maven pom if you have one or in your sonar-project.properties file) or on the analysis command line with -Dsonar.testExecutionReportPaths=[relative path from project root]
Thank you for your response. I have created the sonar-project.properties file in the project root. In that, I added the sonar.testExecutionReportPaths=<project-path>/react-coverage-report.xml
Also, I have other properties where everything is working fine, but testExecutionReportPaths isn’t!
I have created a sonar-project.properties file in the project root and in that I have provided the analysis parameters.
I have Django code coverage report which is being shown in the SonarQube dashboard and also it’s showing the appropriate project name in SonarQube which is defined in sonar-project.properties file. So I’m assuming that SonarQube is able to pick sonar-project.properties. But I’m not sure why sonar.testExecutionReportPaths is not working
Below is how the sonar-project.properties look like.
sonar.projectKey=ProjectKey
sonar.projectName=Project Name
sonar.python.coverage.reportPaths=coverage.xml
sonar.exclusions=*/migrations/*.py
sonar.tests=src
sonar.test.inclusions=**/*.test.js, */tests/*.py
sonar.testExecutionReportPaths=<path>/react-coverage-report.xml
sonar.javascript.lcov.reportPaths=<path>/lcov.info