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.
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
TN:
SF:/source/app/simplebind/child.component.ts
FN:11,(anonymous_3)
FN:17,ChildComponent
FN:22,(anonymous_5)
FNF:3
FNH:3
FNDA:1,(anonymous_3)
FNDA:3,ChildComponent
FNDA:1,(anonymous_5)
DA:1,1
DA:3,1
DA:11,1
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
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 the lcov.info
file.
And ensure javascript plugin is installed in sonar server.
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 be lcov.info
, not /lcov.info
.
If you are using typescript change sonar.typescript.lcov.reportPaths