MS 构建和来自 jenkins 的 SonarQube 分析,无法执行 Sonar,E170001

MS build and SonarQube analysis from jenkins, unable to execute Sonar, E170001

我正在尝试构建一个 .Net 项目并使用 jenkins 开始 sonarqube 代码分析。我做了以下步骤:

  1. 下载 SonarQube
  2. 启动SonarQube服务器:C:...\sonarqube\bin\windows-x86-64\StartSonar.bat
  3. 在 Jenkins 上安装 SonarQube 2.4.4 插件
  4. 转到 http://localhost:8080/configure 并配置 SonarQube 服务器,如下所示:

  5. 转到 http://localhost:8080/configureTools/ 并为 MSBuild 配置 SonarQube 扫描仪,如下所示:

  1. 在 jenkins 中添加了一个作业,将项目配置为使用 MS build 构建,用 SonarQube Scanner for MSBuild - Begin AnalysisSonarQube Scanner for MSBuild - End Analysis 包装了构建步骤:

我的问题: jenkings 检查项目文件并成功构建项目,但分析失败。

这里是相关的控制台输出:

10:53:36.189 INFO  - 113 files to be analyzed
10:53:36.805 INFO  - 0/113 files analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 17.443s
Final Memory: 18M/404M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalStateException: Error when executing blame for file App_Start/BundleConfig.cs
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:102)
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:59)
    at org.sonar.batch.scm.ScmSensor.execute(ScmSensor.java:86)
    at org.sonar.batch.sensor.SensorWrapper.analyse(SensorWrapper.java:57)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
    at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:234)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)
    at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonar.runner.impl.BatchLauncher.delegateExecution(BatchLauncher.java:87)
    ... 9 more
Caused by: org.tmatesoft.svn.core.SVNAuthenticationException: svn: E170001: Authentication required for '<https://subversion.xyz:443> 
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.java:47)
    at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.authenticationFailed(SVNErrorManager.java:41)
    at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.getFirstAuthentication(DefaultSVNAuthenticationManager.java:203)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:716)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:398)
    at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:386)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.performHttpRequest(DAVConnection.java:863)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.exchangeCapabilities(DAVConnection.java:699)
    at org.tmatesoft.svn.core.internal.io.dav.DAVConnection.open(DAVConnection.java:118)
    at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.openConnection(DAVRepository.java:1049)
    at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.hasCapability(DAVRepository.java:877)
    at org.tmatesoft.svn.core.io.SVNRepository.assertServerIsMergeInfoCapable(SVNRepository.java:787)
    at org.tmatesoft.svn.core.io.SVNRepository.getFileRevisions(SVNRepository.java:756)
    at org.tmatesoft.svn.core.internal.wc16.SVNLogClient16.doAnnotate(SVNLogClient16.java:1389)
    at org.tmatesoft.svn.core.internal.wc16.SVNLogClient16.doAnnotate(SVNLogClient16.java:291)
    at org.tmatesoft.svn.core.internal.wc2.old.SvnOldAnnotate.run(SvnOldAnnotate.java:45)
    at org.tmatesoft.svn.core.internal.wc2.old.SvnOldAnnotate.run(SvnOldAnnotate.java:17)
    at org.tmatesoft.svn.core.internal.wc2.SvnOperationRunner.run(SvnOperationRunner.java:21)
    at org.tmatesoft.svn.core.wc2.SvnOperationFactory.run(SvnOperationFactory.java:1235)
    at org.tmatesoft.svn.core.wc2.SvnOperation.run(SvnOperation.java:294)
    at org.tmatesoft.svn.core.wc.SVNLogClient.doAnnotate(SVNLogClient.java:295)
    at org.sonar.plugins.scm.svn.SvnBlameCommand.blame(SvnBlameCommand.java:100)
    ... 37 more
ERROR: 
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
10:53:37.058  Creating a summary markdown file...
Post-processing failed. Exit code: 1
ERROR: Execution of SonarQube Scanner for MSBuild failed (exit code 1)
Finished: FAILURE

错误说:

Caused by: org.tmatesoft.svn.core.SVNAuthenticationException

但我可以使用 sonar-scanner-2.6.1 对 jenkings 之外的项目进行 运行 sonarqube 分析,我在 http://localhost:9000/

上看到了结果

jenkins 在没有分析步骤的情况下构建了很好的项目,所以我不明白 SVN 身份验证怎么会是问题所在。凭据有效。

根据官方文档http://docs.sonarqube.org/display/SCAN/From+Jenkins我要配置一个

MSBuild SonarQube Runner

但我只有一个名为

的部分

SonarQube Scanner for MSBuild.

我错过了什么吗? 运行ner 和 scanner 的区别是什么?

这里发生了几件不同的事情。

当您 运行 在 Jenkins 外部进行分析时,我会猜测您 运行 作为一个用户在该机器上缓存了 SVN 凭据。因此,分析的 'blame' 部分隐含地 运行 与您相同。

当您在 Jenkins 中检出项目时,您明确地提供了作业的凭据,并且这些凭据明确地用于作业的那部分

当您在 Jenkins 中进行 运行 分析时,当您在 Jenkins 之外进行 运行 分析时,该部分作业无法访问正在使用的缓存凭据。它也无权访问您为结账提供给 Jenkins 的凭据。反而。您需要进入您的 SonarQube 服务器并将这些凭据配置到项目中(您也可以将它们作为分析参数传递,但在长 运行 中将它们添加到项目中可能更容易)。

为此,导航到项目主页,然后管理 > 常规设置 > SCM > SVN,并在那里填写您的凭据。