我正在尝试建立一个.Net项目,并开始使用jenkins进行声纳法代码分析 。我做了以下步骤:
下载SonarQube启动SonarQube服务器:C:…\ sonarqube \ bin \ windows-x86-64 \ StartSonar.bat 在Jenkins上安装SonarQube 2.4.4插件 转到http:// localhost:8080 / configure并配置SonarQube服务器,如下所示:在此处输入图片说明
转到http:// localhost:8080 / configureTools /并为MSBuild配置SonarQube Scanner,如下所示:
在此处输入图片说明
在jenkins中添加了一个工作,将项目配置为使用MS build进行构建,SonarQube Scanner for MSBuild - Begin Analysis并使用和包裹构建步骤SonarQube Scanner for MSBuild - End Analysis:在此处输入图片说明我的问题:抽签检出项目文件并成功构建项目,但分析失败。
这是相关的控制台输出:
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$1.delegateExecution(BatchLauncher.java:91) at org.sonar.runner.impl.BatchLauncher$1.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$1.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
错误提示:
引起原因:org.tmatesoft.svn.core.SVNAuthenticationException
但是我可以使用 sonar-scanner-2.6.1 在jenkings之外的项目上运行声纳分析,并且可以在http:// localhost:9000 /上看到结果
和
jenkins在没有分析步骤的情况下可以很好地构建项目,因此我不 理解SVN身份验证可能是问题所在。凭证 有效。
根据官方文档 http://docs.sonarqube.org/display/SCAN/From+Jenkins,我必须配置一个
MSBuild SonarQube 运行器
但我只有一节
用于MSBuild的SonarQube 扫描仪。
我错过了什么吗?流道和扫描仪之间的区别是什么?
这里发生了几种不同的事情。
当您在Jenkins外部运行分析时,我会猜测您是以在该计算机上缓存了SVN凭据的用户身份运行该分析的。因此,分析的“非议”部分会像您一样隐式运行。
在Jenkins中签出项目时,您显式地为作业提供了凭证,并且这些凭证被显式地用于 作业的该部分 。
在Jenkins中运行分析时,当您在Jenkins之外运行分析时,该部分工作无法访问正在使用的缓存凭据。也不是有机会获得您所提供詹金斯结账凭据。代替。您将需要进入SonarQube服务器并将这些凭据配置到项目中(您也可以将它们作为分析参数传递,但是从长远来看,将它们添加到项目中可能更容易)。
为此,请导航到项目主页,然后依次单击管理>常规设置> SCM> SVN,然后在其中填写您的凭据。