I have karma configured which gives me coverage report perfectly fine.
It gives me in lcov format.
Referring to this http://docs.sonarqube.org/display/PLUG/JavaScript+Coverage+Results+Import
lcov report can be uploaded to sonar.
I have installed the plugin in sonar. My project builds through ant scripts so i have added
<property name="sonar.javascript.lcov.reportPath" value="/lcov.info"/>
I read on some blogs that lcov needs to be corrected so that sonar can understand it. I am done with it.
So lcov gets generated and is in the correct format.
For some reason the sonar is unable to find my lcov report and does not parse the report. I checked my path it is correct.
Am I missing on something ?
Any help would be appreciated.
The path of your LCOV report is set to
/lcov.info
which looks like an absolute path: is your report really located at the root of your file system? If your LCOV report is not at the root of the file system but at the root of your project, then the path of the LCOV report should belcov.info
, not/lcov.info
.You will have to add a property called
<sonar.javascript.lcov.reportPath>
for sonar to identify lcov file. This property should point to the location of thelcov.info
file.And ensure javascript plugin is installed in sonar server.
If you are using typescript change
sonar.typescript.lcov.reportPaths
lcov.info may have incorrect file paths. Other tools like coveralls work fine and sonar expects the relative path. Here is how my lcov.info looked. /source/app/simplebind/child.component.ts was incorrect and sonarqube expected src/app/simplebind/child.component.ts
Use following command to replace the file path in lcov.info. You can execute it after gulp build from your jenkins shell.
sed -i -- 's/\/source/src/g' report/remap/lcov.info
Works fine for Angular2 Typescript Sonar plugin as well. https://github.com/Pablissimo/SonarTsPlugin