【问题标题】:Timout on SonarQube Analysis on TFS2017TFS 2017 上的 SonarQube 分析超时
【发布时间】:2018-03-28 17:23:02
【问题描述】:

我们的设置是 SonarQube 服务器 5.6.5 LTS 和 TFS2017 本地服务器。

我正在对一个大型解决方案进行代码分析,构建过程大约需要 15 分钟,而完成分析构建步骤的时间也差不多。 在“完成 SonarQube 分析”构建步骤中,我收到以下错误:

2017-01-31T08:52:44.8355200Z 09:52:44.741  Post-processing succeeded.
2017-01-31T08:52:46.9293440Z Waiting on the SonarQube server to finish processing in order to determine the quality gate status.
2017-01-31T08:57:47.7364532Z ##[error]System.Management.Automation.RuntimeException: The analysis did not complete in the allotted time of 300 seconds. Consider setting the build variable SonarQubeAnalysisTimeoutInSeconds to a higher value. ---> System.Management.Automation.RuntimeException: The analysis did not complete in the allotted time of 300 seconds. Consider setting the build variable SonarQubeAnalysisTimeoutInSeconds to a higher value.
2017-01-31T08:57:47.7364532Z    --- Ende der internen Ausnahmestapelüberwachung ---
2017-01-31T08:57:47.7364532Z    bei System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
2017-01-31T08:57:47.7364532Z    bei System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
2017-01-31T08:57:47.7364532Z    bei System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
2017-01-31T08:57:47.7364532Z    bei System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2017-01-31T08:57:47.7364532Z    bei System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
2017-01-31T08:57:47.7364532Z    bei Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
2017-01-31T08:57:47.7676884Z ##[error]LegacyVSTSPowerShellHost.exe completed with return code: -1.
2017-01-31T08:57:47.7676884Z ##[section]Finishing: Complete the SonarQube analysis

构建步骤控制选项中的超时设置为零/无限。我在哪里可以设置SonarQubeAnalysisTimeoutInSeconds 或者我应该设置更高的其他超时设置吗?

如果我在准备构建任务中取消选中“在构建摘要中包含完整分析报告”,则构建运行绿色。 但在这两种情况下,SonarQube 服务器日志中都有一个OutOfMemoryError

2017.01.31 09:54:10 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute duplication measures | time=399ms
2017.01.31 09:54:56 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVnzuYyFhG9cSXnted2v
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Unknown Source) ~[na:1.8.0_121]
    at java.lang.AbstractStringBuilder.ensureCapacityInternal(Unknown Source) ~[na:1.8.0_121]
    at java.lang.AbstractStringBuilder.append(Unknown Source) ~[na:1.8.0_121]
    at java.lang.StringBuilder.append(Unknown Source) ~[na:1.8.0_121]
    at org.sonar.server.computation.step.DuplicationDataMeasuresStep$DuplicationVisitor.appendDuplication(DuplicationDataMeasuresStep.java:131) ~[sonar-server-5.6.5.jar:na]
...

这两个错误是否相关?

【问题讨论】:

  • 当您选中“在构建摘要中包含完整分析报告”时,任务将等待分析完成,然后再继续执行下一个任务。如果您想将质量门状态放在构建报告中,这可能很有用,但会减慢构建速度。服务器上 SonarQube 进程的可用内存是多少?您可能需要查看System Requirements page 以了解有关 SonarQube 性能的更多信息。
  • 我以前知道这个页面,因为我们在服务器上有 4GB 内存,所以我不关心配置 javaOpts 属性。我现在将这些值明确设置为建议的 2gb Xmx 和 512mb Xms - 现在一切都很好。

标签: tfs sonarqube msbuild-task


【解决方案1】:

这两个错误相关的。您的构建任务正在等待服务器响应构建结果,但由于OutOfMemoryError 而没有响应。

要授予进程更多内存,请编辑$SONARQUBE_HOME/conf/sonar.properties,取消注释sonar.ce.javaOpts 行,并根据需要调整值。

【讨论】:

  • 这很明显,但不要忘记在更改这些值后重新启动 SonarQube 服务器实例。又花了我半个小时左右......
【解决方案2】:

SQ 版本 6.4 和 SonarQube TFS 扩展版本 SonarSource.sonarqube-3.0.2 没有这个问题。但我们刚刚升级到 SQ v7.0 并开始出现此问题。

即使设置了构建变量“SonarQubeAnalysisTimeoutInSeconds”,也无法正常工作。

错误 SonarQubeAnalysisTimeoutInSeconds 设置为 600,将用于轮询 SonarQube 任务的完成情况。 分析未在分配的 600 秒时间内完成。考虑将构建变量 SonarQubeAnalysisTimeoutInSeconds 设置为更高的值。

问候, 圣

【讨论】:

    猜你喜欢
    • 2015-08-15
    • 1970-01-01
    • 2018-05-19
    • 2018-06-25
    • 2017-08-16
    • 2017-04-14
    • 2018-01-24
    • 2017-11-07
    • 2015-09-24
    相关资源
    最近更新 更多