对文件执行 blame 时出现 SonarQube 错误

SonarQube error when executing blame for file

我最近从 SonarQube 5.1.2 升级到 SonarQube 5.6。现在我得到一个 IllegalStateException "Error when executing blame for file"。在 Eclipse 和 Jenkins 中使用我的 ant 脚本构建时会发生这种情况。在 Jenkins 中错误更完整,指示 SVNAuthenticationException E170001: Negotiate authentication failed: 'No valid credentials provided'。

SonarQube 管理 -> 常规设置 -> SCM -> SVN 中存在有效凭据。它们与我在 5.1.2 中使用的凭据相同,并且 blame 功能可以正常工作,并将问题分配给各个开发人员。此外,我的构建脚本使用相同的凭据填充 sonar.svn.username 和 sonar.svn.password.secured。

在 5.1.2 中,我使用的是 sonar-issue-assign-plugin。我看到它现在已被弃用,事实上,如果该插件存在,SonarQube 5.6 将无法成功启动。不幸的是,无论取代它的是什么,都不适合我。

我查看了同样错误的问题的答案 and

编辑:我仍然停留在这个问题上。我在 SonarQube Administration > Generate Settings > SCM > SVN 中重新输入了凭据并重新启动了服务器。同样的结果。这是异常堆栈跟踪的最后一部分:

原因:org.tmatesoft.svn.core.SVNAuthenticationException:svn:E170001:协商认证失败:'No valid credentials provided' 在 org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:62) 在 org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51) 在 org.tmatesoft.svn.core.internal.io.dav.http.DefaultHTTPNegotiateAuthentication$1.run(DefaultHTTPNegotiateAuthentication.java:175) 在 org.tmatesoft.svn.core.internal.io.dav.http.DefaultHTTPNegotiateAuthentication$1.run(DefaultHTTPNegotiateAuthentication.java:166) 在 org.tmatesoft.svn.core.internal.io.dav.http.DefaultHTTPNegotiateAuthentication.authenticate(DefaultHTTPNegotiateAuthentication.java:221) 在 org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:477) 在 org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:398) 在 org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:386) 在 org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:863) 在 org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:699) 在 org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:118) 在 org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1049) 在 org.tmatesoft.svn.core.internal.io.dav.DAVRepository.hasCapability(DAVRepository.java:877) 在 org.tmatesoft.svn.core.io.SVNRepository.assertServerIsMergeInfoCapable(SVNRepository.java:787) 在 org.tmatesoft.svn.core.io.SVNRepository.getFileRevisions(SVNRepository.java:756) 在 org.tmatesoft.svn.core.internal.wc2.remote.SvnRemoteAnnotate.run(SvnRemoteAnnotate.java:111) 在 org.tmatesoft.svn.core.internal.wc2.remote.SvnRemoteAnnotate.run(SvnRemoteAnnotate.java:35) 在 org.tmatesoft.svn.core.internal.wc2.SvnOperationRunner.run(SvnOperationRunner.java:21) 在 org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1235) 在 org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:294) 在 org.tmatesoft.svn.core.wc.SVNLogClient.doAnnotate(SVNLogClient.java:295) 在 org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:100) ... 64 更多

编辑 2:我已经 运行 使用 sonarqube-ant-task-2 将其作为 Ant 任务 5.jar 并且我已经运行 它作为 Jenkins 中一个单独的构建步骤使用 SonarQube 插件(版本 2.4.4)得到了相同的结果。我仍然不知道为什么在尝试分配责任时找不到我的 SVN 凭据。

我将回答我自己的问题,因为我找到了一个可行的解决方案。这似乎是 SVNKit 的一个问题,我的 SVN 服务器正在使用 NTLM 或协商身份验证,而 SonarQube 插件调用的 tmatesoft svn 代码在我的环境中不支持它。

将以下内容添加到 Jenkins 主机 JVM 选项可解决问题:

-Dsvnkit.http.methods=Basic,Digest,Negotiate,NTLM

Solution found here.

这适用于通过在调用 ant 脚本时将其添加到 JVM 选项来从 Ant 调用声纳,它也适用于添加到 JVM 选项时的 Jenkins 构建任务执行 SonarQube 扫描仪。