C# sonarqube 插件问题

Issue with C# sonarqube plugin

我已经安装了 SonarQube 5.6 一年了,它与 TFS 集成。安装了一些额外的插件,C#、dependency-check、fxcop、java、Checkmarx、scm-cvs、scm-git、scm-svn 和 scm-tfvc。 一切正常。今天它开始构建失败并出现错误 2017-06-26T17:54:22.7387533Z Downloading SonarQube.MSBuild.Runner.Implementation.zip from http://xxxxxxx:9000/static/csharp/SonarQube.MSBuild.Runner.Implementation.zip to E:\agnt\_work\.sonarqube\bin\SonarQube.MSBuild.Runner.Implementation.zip 2017-06-26T17:54:22.7397520Z ##[error]Could not find a file on the SonarQube server. Url: http://xxxxxxxxxx:9000/static/csharp/SonarQube.MSBuild.Runner.Implementation.zip 2017-06-26T17:54:22.7407523Z ##[error]Failed to update the SonarQube Scanner for MSBuild binaries. Check the server url, verify that the C# plugin is correctly installed on the SonarQube server and that the SonarQube server has been restarted. 2017-06-26T17:54:22.7417526Z ##[error]Pre-processing failed. Exit code: 1 2017-06-26T17:54:22.8678238Z ##[error]System.Exception: Unexpected exit code received from batch file: 1 2017-06-26T17:54:22.8698250Z ##[error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeBatchScriptCmdlet.ProcessRecord() 2017-06-26T17:54:22.8708248Z ##[error] at System.Management.Automation.CommandProcessor.ProcessRecord()

从错误来看,我可以认为它与C# 插件有关。我检查了 /extensions/plugins 下的那个插件,它就在那里。我认为这可能是兼容性问题,我尝试将其升级到最新的 6.0

安装6.0后再次尝试,出现同样的错误。

我也尝试过使用相同插件的旧版本。试过 5.3、5.0。在 /plugins 下手动复制 jar 文件后。试图重新启动声纳服务器,但没有成功启动。我收到如下错误,

2017.06.26 18:31:11 ERROR web[o.s.s.p.Platform] Fail to stop server - ignored java.lang.IllegalStateException: Cannot stop. Current container state was: CONSTRUCTED at org.picocontainer.lifecycle.DefaultLifecycleState.stopping(DefaultLifecycleState.java:72) ~[picocontainer-2.15.jar:na] at org.picocontainer.DefaultPicoContainer.stop(DefaultPicoContainer.java:794) ~[picocontainer-2.15.jar:na] 2017.06.26 18:31:11 ERROR web[o.a.c.c.C.[.[.[/]] Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener java.lang.IllegalStateException: Fail to load plugin FxCop [fxcop] at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:74) ~[sonar-server-5.6.jar:na] at org.sonar.server.platform.platformlevel.PlatformLevel4.start(PlatformLevel4.java:691) ~[sonar-server-5.6.jar:na] at org.sonar.server.platform.Platform.start(Platform.java:216) ~[sonar-server-5.6.jar:na] Caused by: java.lang.IllegalStateException: Unable to register extension org.sonar.api.config.PropertyDefinition at org.sonar.core.platform.ComponentContainer.addExtension(ComponentContainer.java:248) ~[sonar-core-5.6.jar:na] at org.sonar.server.plugins.ServerExtensionInstaller.installExtension(ServerExtensionInstaller.java:111) ~[sonar-server-5.6.jar:na] at org.sonar.server.plugins.ServerExtensionInstaller.installExtensions(ServerExtensionInstaller.java:66) ~[sonar-server-5.6.jar:na] Caused by: org.picocontainer.PicoCompositionException: Duplicate Keys not allowed. Duplicate for 'org.sonar.api.config.PropertyDefinition-sonar.cs.fxcop.timeoutMinutes'at org.picocontainer.DefaultPicoContainer.addAdapterInternal(DefaultPicoContainer.java:438) ~[picocontainer-2.15.jar:na] 2017.06.26 18:31:11 ERROR web[o.a.c.c.StandardContext] One or more listeners failed to start. Full details will be found in the appropriate container log file 2017.06.26 18:31:11 ERROR web[o.a.c.c.StandardContext] Context [] startup failed due to previous errors 2017.06.26 18:31:11 WARN web[o.a.c.l.WebappClassLoaderBase] The web application [ROOT] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread 2017.06.26 18:31:11 WARN web[o.s.p.ProcessEntryPoint] Fail to start web java.lang.IllegalStateException: Webapp did not start at org.sonar.server.app.EmbeddedTomcat.isUp(EmbeddedTomcat.java:84) ~[sonar-server-5.6.jar:na]at org.sonar.server.app.WebServer.isUp(WebServer.java:47) [sonar-server-5.6.jar:na]at org.sonar.process.ProcessEntryPoint.launch(ProcessEntryPoint.java:105) ~[sonar-process-5.6.jar:na]at org.sonar.server.app.WebServer.main(WebServer.java:68) [sonar-server5.6.jar:na]

有人可以帮忙解决这个问题吗?

您还需要更新 Scanner for MsBuild。旧版本与 SonarC# 6+ 不兼容。

我通过删除 FxCop 插件解决了这个问题。不知何故,该插件停止工作。可能是我使用的与 C# 插件不兼容的版本。我安装了 C# 插件版本 5.0(最新是 6.0)

如上所述,如果我想使用 C# 最新版本,我需要为 MSBuild 更新声纳扫描器。