当我的 lcov 文件中的路径是绝对路径时,Sonar 不会检索我的项目的覆盖率信息。对于文件:
TN:
SF:/mnt/vg01-data01/jenkins/<jenkins.myhost.com>/jenkins_home/workspace/<job1>/src/app.js
FN:,(anonymous_0)
FN:,(anonymous_1)
FNF:2
FNH:2
FNDA:1,(anonymous_0)
FNDA:2,(anonymous_1)
DA:3,1
DA:4,1
DA:6,1
DA:7,1
DA:8,1
DA:9,1
DA:11,1
DA:18,1
DA:19,1
DA:22,2
DA:27,1
LF:11
LH:11
BRF:0
BRH:0
end_of_record
....
我收到以下警告:
...
05:06:27.565 INFO: Analysing [/srv/jenkins/<jenkins.myhost.com>/jenkins_home/workspace/<job1>/coverage/lcov.info]
05:06:27.574 DEBUG: Default value of zero will be saved for file: src/app.js
05:06:27.574 DEBUG: Because was not present in LCOV report.
05:06:27.578 DEBUG: Default value of zero will be saved for file: src/app.spec.js
05:06:27.578 DEBUG: Because was not present in LCOV report.
05:06:27.579 DEBUG: Default value of zero will be saved for file: src/js/form/form.ctrl.js
05:06:27.579 DEBUG: Because was not present in LCOV report.
05:06:27.580 DEBUG: Default value of zero will be saved for file: src/js/form/form.module.js
05:06:27.580 DEBUG: Because was not present in LCOV report.
05:06:27.581 DEBUG: Default value of zero will be saved for file: src/js/success/success.ctrl.js
...
但是,默认情况下,业力(和 istambul)正在生成具有绝对路径的文件。
如果我更改路径以使它们相对,则 sonarqube 会正确报告覆盖范围。但是,我必须确保在向声纳报告之前始终运行“lcov 补丁”脚本。
声纳是否支持绝对路径?其他团队正在为这个问题做些什么?这些是我正在使用的版本:
- 业力@1.3.0 & 业力覆盖@1.1.1
- 声纳 6.1 和 JavaScript 插件 2.14
更新:我用作业中的确切文件和日志替换了我看到的文件和日志(出于安全原因,我仍然必须更改主机和作业的名称。)
2016 年 3 月更新:我已向 Istambul 发送了一个拉取请求,以启用生成具有相对路径的 lcov 文件。我希望这能解决这个问题https://github.com/gotwarlost/istanbul/pull/771