0

我在自己的计算机上运行了 MSBuild.SonarQube.Runner.exe,一切正常。我现在正在尝试自动化这项工作并将其交给 Bamboo。我使用的是相同的 SonarQube 配置(但与 Windows 2008 R2 Server 与 Windows 7 的环境不同)。我正在使用 MSBuild.SonarQube.Runner.exe 和最简单的配置文件(仅 MySQL 服务器)。

我的错误表明了 Dinesh 桌面的路径(如果我没记错的话,他是 Sonar Qube 开发人员)

运行MSBuild.SonarQube.Runner.exe end后会发生此错误 。任何想法 ?

18:00:06  Writing processing summary to E:\bamboo-home\xml-data\build-dir\SON-SVACN0-TEST\.sonarqube\out\ProjectInfo.log
18:00:06  Creating directory: E:\bamboo-home\xml-data\build-dir\SON-SVACN0-TEST\.sonarqube\bin\sonar-runner
18:00:06  The SONAR_RUNNER_HOME environment variable is not required and will be ignored.
18:00:06  Calling the sonar-runner...
18:00:06  SONAR_RUNNER_OPTS is not configured. Setting it to the default value of -Xmx1024m

Unhandled Exception: System.ArgumentException: Item has already been added. Key in dictionary: 'bamboo_capability_system_builder_snr_Sonar_Runner'  Key being added: 'bamboo_capability_system_builder_snr_Sonar_runner'
  at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
  at System.Collections.Hashtable.Add(Object key, Object value)
  at System.Collections.Specialized.StringDictionaryWithComparer.Add(String key, String value)
  at System.Diagnostics.ProcessStartInfo.get_EnvironmentVariables()
  at SonarQube.Common.ProcessRunner.SetEnvironmentVariables(ProcessStartInfo psi, IDictionary`2 envVariables, ILogger logger) in c:\Users\dinesh\Desktop\sonarsource\sonar-msbuild-runner\SonarQube.Common\ProcessRunner.cs:line 151
  at SonarQube.Common.ProcessRunner.Execute(String exeName, String args, String workingDirectory, Int32 timeoutInMilliseconds, IDictionary`2 envVariables, ILogger logger) in c:\Users\dinesh\Desktop\sonarsource\sonar-msbuild-runner\SonarQube.Common\ProcessRunner.cs:line 87
  at SonarRunner.Shim.SonarRunnerWrapper.ExecuteJavaRunner(ILogger logger, String exeFileName, String propertiesFileName) in c:\Users\dinesh\Desktop\sonarsource\sonar-msbuild-runner\SonarRunner.Shim\SonarRunner.Wrapper.cs:line 114
  at SonarRunner.Shim.SonarRunnerWrapper.Execute(AnalysisConfig config, ILogger logger) in c:\Users\dinesh\Desktop\sonarsource\sonar-msbuild-runner\SonarRunner.Shim\SonarRunner.Wrapper.cs:line 68
  at SonarQube.TeamBuild.PostProcessor.Program.Main() in c:\Users\dinesh\Desktop\sonarsource\sonar-msbuild-runner\SonarQube.TeamBuild.PostProcessor\Program.cs:line 51
4

2 回答 2

0

在 Windows 上,环境变量不区分大小写。出于某种原因,您试图同时定义两者:

  1. 竹能力_系统_建造者_snr_Sonar_R unner
  2. 竹能力_系统_建造者_snr_Sonar_ r unner

.NET 框架不太支持此功能,请参阅: https ://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.Process/src/System/Diagnostics/ProcessStartInfo.cs#L97

任何对ProcessStartInfo.Environment当存在具有多个大小写的相同环境变量时的调用都将导致您看到的失败。

所以 - 也许这需要在 CoreFX(.NET 框架)中修复 - 但我认为不需要对 MSBuild SonarQube Runner 本身进行更改。

另一个解决方法是让 Bamboo 不要多次定义相同的环境变量。例如,设置环境变量的 Windows 用户界面会在您尝试定义FOO何时foo已定义时覆盖该值。

于 2015-08-12T08:48:17.300 回答
0

Bamboo 正在创建许多环境变量。问题是它创建了两次相同的变量(R unner vs r unner)。

bamboo_capability_system_builder_snr_Sonar_Runner=E:\sonar-runner-2.3
bamboo_capability_system_builder_snr_Sonar_runner=E:\sonar-runner-2.3
bamboo_capability_system_builder_snr_Sonar_runners=E:\sonar-runner-2.3

我认为 MSBuild.SonarQube.Runner 中有一个错误,因为它应该检查密钥是否已包含在此函数中

  at SonarQube.Common.ProcessRunner.SetEnvironmentVariables(ProcessStartInfo psi, IDictionary`2 envVariables, ILogger logger) in c:\Users\dinesh\Desktop\sonarsource\sonar-msbuild-runner\SonarQube.Common\ProcessRunner.cs:line 151

作为一种快速解决方法,我决定在我的竹脚本中将两个变量之一设置为 null:

set bamboo_capability_system_builder_snr_Sonar_runner=
于 2015-08-12T07:12:50.353 回答