Sonarqube:缺少以下文件的责备信息

时间:2016-05-25 08:59:00

标签: java git maven jenkins sonarqube

我在SonarQube的分析过程中收到警告Missing blame information for the following files

[INFO] [22:19:57.714] Sensor SCM Sensor
[INFO] [22:19:57.715] SCM provider for this project is: git
[INFO] [22:19:57.715] 48 files to be analyzed
[INFO] [22:19:58.448] 0/48 files analyzed
[WARN] [22:19:58.448] Missing blame information for the following files:
(snip 48 lines)
[WARN] [22:19:58.449] This may lead to missing/broken features in SonarQube
[INFO] [22:19:58.449] Sensor SCM Sensor (done) | time=735ms

我正在使用SonarQube 5.5,分析由Maven在Jenkins工作中完成,在多模块Java项目上完成。 安装了Git插件1.2。

在任何违规文件的bash shell中手动运行git blame会产生预期的输出。

我发现的相关问题都与SVN有关,我的问题是Git。

如何获取Sonarqube的git blame信息?

3 个答案:

答案 0 :(得分:14)

原因是JGit bug。 JGit不支持.gitattributes。我的.gitattributes中有ident。普通控制台git检查了源代码,在ident宏上应用了$Id$,但随后JGit忽略了这一点并看到了一个尚未提交的差异,而实际上并没有这样做。一个。

SonarQube mailing list上友好的人帮助了我,建议使用standalone JGit command line distribution进行调试:

chmod +x /where/is/org.eclipse.jgit.pgm-<version>-r.sh
/where/is/org.eclipse.jgit.pgm-<version>-r.sh blame -w /path/to/offending/file

这个特殊的JGit漏洞已经解决了5年多了,我不希望它很快就会解决,所以我从所有来源中删除了$Id$个宏。

这是我用来删除所有$Id$宏的(Bash)代码:

find */src -name "*.java" | xargs -n 1 sed -i '/$Id.*$/d'
find */src -name "*.java" | xargs git add
git commit -m "Remove $Id$ macros"
git push

答案 1 :(得分:4)

我遇到了类似的问题:我的项目中的文件是在构建过程中创建的,并未存储在源代码管理中。就我而言,它是api.json

在Team City的SonarQube跑步者构建步骤中,我将此文件添加到附加参数中的排除项

-Dsonar.exclusions=**/spec/api.json

并且错误消失了。

答案 2 :(得分:-1)

我遇到了一个在Sonar升级后停止工作的版本遇到了这个问题。

对我来说,问题是 Jenkins作业被配置为在从git 中提取时执行Shallow Clone。这并没有足够的历史记录,因此Sonar 5.6.6无法进行分析,因为责备信息不包含在浅层副本中。我在运行Sonar时使用了 -X 选项来查看它正在阻塞的实际提交号。

我是我的情况我只是取消选中浅复制复选框和BAM,它再次起作用(虽然更慢)! enter image description here