4

我正在尝试使用 MSbuild.SonarQube.Runner 为 SonarQube 使用 C# 插件

SonarQube 服务器 - 4.5.6 操作系统 - Windows 32 位机器 数据库 - MySQL 5.6.17 MSbuild.SonarQube.Runner - 1.0.2

按照http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild中提到的步骤

从项目的文件夹中运行所有 3 个命令。

  1. 第一次尝试

SonarQube.Analysis.xml 文件内容

<?xml version="1.0" encoding="utf-8" ?>
<SonarQubeAnalysisProperties  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
   <Property Name="sonar.host.url">http://x.x.x.x:9000</Property>
   <Property Name="sonar.login">userabc</Property>
   <Property Name="sonar.password">1234</Property>
   <!-- Required only for versions of SonarQube prior to 5.2 -->
   <Property Name="sonar.jdbc.url">jdbc:mysql://x.x.x.x:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance</Property>
   <Property Name="sonar.jdbc.username">sonar</Property>
   <Property Name="sonar.jdbc.password">sonar</Property>
</SonarQubeAnalysisProperties>

我尝试运行第一个命令 - MSBuild.SonarQube.Runner.exe begin /k:prj_K /n:prj /v:1.0

但我得到以下错误

 Unable to read the SonarQube analysis settings file 'C:\Sonar\sonarqube-4.5.6\MSBuild.SonarQube.Runner-1.0.2\SonarQube.Analysis.xml'. Please fix the content of this file. 
  1. 第二次尝试

然后将 sonar.jdbc.url 的属性值更改为

<Property Name="sonar.jdbc.url">jdbc:mysql://x.x.x.x:3306/sonar?useUnicode=true</Property>   

在此第一个命令成功之后。

第二条命令

 msbuild /t:Rebuild

也是成功的

第三条命令

 MSBuild.SonarQube.Runner.exe end

我得到以下日志

 INFO: ------------------------------------------------------------------------
 INFO: EXECUTION SUCCESS
 INFO: ------------------------------------------------------------------------
 Total time: 2:02.225s
 Final Memory: 11M/121M
 INFO: ------------------------------------------------------------------------
 Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
 The sonar-runner did not complete successfully
 16:36:59.242  Creating a summary markdown file...
 Post-processing failed. Exit code: 1    

后处理失败。退出代码:1

我错过了什么?

此外,SonarQube.Analysis.xml 中的属性 - sonar.jdbc.username 和 - sonar.jdbc.password

为什么需要它们?

提前致谢。

4

2 回答 2

2

MSBuild.SonarQube.Runner.exe错误地报告处理失败,因为有关MaxPermSize的警告已写入错误流。

这是一个已知问题,由 SONARMSBRU-202跟踪。它应该在SonarQube Scanner for MSBuild的下一个版本中得到修复。

解决方法是通过不设置MaxPermSize来删除警告。

于 2016-01-13T09:35:12.220 回答
0

我犯了同样的错误。当我将它添加到PATH. 或者,在添加MSBUILDto之后PATH,即使 MSBUILD 被移动到另一个文件夹,也会收到相同的错误。

于 2018-12-01T18:12:04.223 回答