问题描述
我们有一个 Jenkins 作业,其中包含一堆 javascript 文件.我们通过 grunt 构建我们的项目,并在构建结束时运行 JSCover 来运行我们的单元测试并收集代码覆盖率.这一切都有效.我们得到了一个不错的 LCOV 文件.
We have a Jenkins job that contains a bunch of javascript files. We build our project via grunt, and at the end of the build we run JSCover to run our unit tests and collect code coverage. It all works. We get a nice LCOV file.
我们现在想将 LCOV 文件上传到 Sonar,但我不知道该怎么做.我们正在将 Jenkins 项目构建为一个自由风格的项目.
We now want to upload the LCOV file to Sonar, and I'm not sure how to do this. We are building our project from Jenkins as a free style project.
我尝试使用各种声纳项目属性,但不喜欢:
I tried playing around with various project properties for sonar, but no love:
# project metadata (required)
sonar.projectKey=my.project
sonar.projectName=My Project
sonar.projectVersion=1.0
# path to source directories (required)
sonar.sources=src
# The value of the property must be the key of the language.
sonar.language=java (I tried js and javascript, but no love. Plugin is not installed. Actually, I don't care about the language, since I am already generating the LCOV file during the build. I just need Sonar to use this LCOV file.)
# Advanced parameters
sonar.javascript.jstestdriver.reportsfolder=target/surefire-reports
sonar.javascript.jstestdriver.coveragefile=target/test-coverage/jscover.lcov
sonar.dynamicAnalysis=reuseReports
我怀疑问题出在高级参数"下,但我不知道如何告诉 Sonar,请使用我的 LCOV 文件进行代码覆盖".
I suspect the problem is under the "Advanced Parameters", but I don't know how to tell Sonar, "Please use my LCOV file for Code Coverage".
推荐答案
你可以看看此示例项目,其中 LCOV 报告的路径在 sonar-project.properties
文件中指定.
You can have a look at this sample project where the path to a LCOV report is specified in the sonar-project.properties
file.
请注意,在 Javascript 插件的最新版本中,一些属性名称已更改.
Note that some property names have changed in the last version of the Javascript plugin.
这篇关于如何告诉 Sonar 使用我的 LCOV 文件进行代码覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!