【问题标题】:SonarQube 5.1 execution error using Bamboo使用 Bamboo 的 SonarQube 5.1 执行错误
【发布时间】:2015-11-03 23:43:04
【问题描述】:

我在自己的计算机上运行了 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

【问题讨论】:

  • 仅供参考,您在我的本地计算机上看到了路径,因为我已经执行了发布,其中包括 *.pdb 文件。这些文件包含机器上用于构建程序集的源文件的绝对路径。有了它们,堆栈跟踪就增加了源信息。您遇到的失败的实际根本原因是无关的。
  • 好的,谢谢您的留言。

标签: msbuild sonarqube sonarqube5.1


【解决方案1】:

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

  1. bamboo_capability_system_builder_snr_Sonar_Runner
  2. bamboo_capability_system_builder_snr_Sonar_runner

.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 不要多次定义相同的环境变量。例如,如果您在已定义 foo 时尝试定义 FOO,则用于设置环境变量的 Windows 用户界面会覆盖该值。

【讨论】:

    【解决方案2】:

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

    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=
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-22
      • 2014-11-26
      • 1970-01-01
      • 2015-01-16
      • 2017-07-20
      • 2017-10-11
      • 2017-11-02
      • 1970-01-01
      相关资源
      最近更新 更多