繁体   English   中英

SonarQube MSBuild与Jenkins的集成失败,在命令行上工作正常

[英]SonarQube MSBuild integration failed with Jenkins, works fine on command line

我正在用声纳分析我的.NET项目,我想用我的jenkins构建服务器将其自动化。

我使用MSBuild 14.0.23107.0,sonarqube 6.7.1.35068,sonar-scanner-msbuild-4.0.2.892,sonar-csharp-plugin-6.7.1.4347,Jenkins 2.89.3

我尝试了jenkins“用于MSBuild的SonarQube扫描仪-开始分析”和“用于MSBuild的SonarQube扫描仪-结束分析”的构建步骤,但是它们失败并显示以下错误消息:

SonarQube MSBuild集成失败:SonarQube无法收集有关您的项目的必需信息。 可能的原因:

  1. 该项目尚未构建-必须在开始和结束步骤之间构建该项目
  2. 使用了不支持的MSBuild版本来生成项目。 当前支持MSBuild 14.0或更高版本
  3. 尚未从同一文件夹启动所有开始,构建或结束步骤

我尝试了几件事,然后切换到具有以下内容的Windows批处理文件构建步骤:

SonarQube.Scanner.MSBuild.exe begin /k:"eGate" /v:"%SVN_REVISION%" /d:sonar.login="%SONAR_AUTH_TOKEN%"
MSBuild.exe /property:Configuration=AutoBuild /t:Rebuild
SonarQube.Scanner.MSBuild.exe end /d:sonar.login="%SONAR_AUTH_TOKEN%"

因为这是我能想到的最简单的例子。 它仍然失败:

12:41:39 C:\Jenkins\workspace\eGate>SonarQube.Scanner.MSBuild.exe begin /k:"eGate" /v:"8503" /d:sonar.login="******" 
12:41:39 SonarQube Scanner for MSBuild 4.0.2
12:41:39 Default properties file was found at C:\sonarqube\bin\SonarQube.Analysis.xml
12:41:39 Loading analysis properties from C:\sonarqube\bin\SonarQube.Analysis.xml
12:41:39 Pre-processing started.
12:41:39 Preparing working directories...
12:41:39 12:41:39.232  Updating build integration targets...
12:41:39 12:41:39.243  Fetching analysis configuration settings...
12:41:39 12:41:39.403  Provisioning analyzer assemblies for cs...
12:41:39 12:41:39.404  Installing required Roslyn analyzers...
12:41:39 12:41:39.44  Pre-processing succeeded.
12:41:39 
12:41:39 C:\Jenkins\workspace\eGate>MSBuild.exe /property:Configuration=AutoBuild /t:Rebuild 
12:41:39 Microsoft (R)-Buildmodul, Version 14.0.23107.0

SNIP

12:42:28 
12:42:28     4 Warnung(en)
12:42:28     0 Fehler
12:42:28 
12:42:28 Verstrichene Zeit 00:00:48.97
12:42:28 
12:42:28 C:\Jenkins\workspace\eGate>SonarQube.Scanner.MSBuild.exe end /d:sonar.login="******" 
12:42:28 SonarQube Scanner for MSBuild 4.0.2
12:42:28 Default properties file was found at C:\sonarqube\bin\SonarQube.Analysis.xml
12:42:28 Loading analysis properties from C:\sonarqube\bin\SonarQube.Analysis.xml
12:42:28 Post-processing started.
12:42:28 The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
12:42:28 Possible causes:
12:42:28   1. The project has not been built - the project must be built in between the begin and end steps
12:42:28   2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
12:42:28   3. The begin, build or end steps have not all been launched from the same folder
12:42:28 Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
12:42:28 12:42:28.73  Creating a summary markdown file...
12:42:28 12:42:28.732  Post-processing failed. Exit code: 1
12:42:28 
12:42:28 C:\Jenkins\workspace\eGate>exit 1 
12:42:28 Build step 'Windows Batch-Datei ausführen' marked build as failure
12:42:29 Finished: FAILURE

有趣的是,当我打开命令行时,切换到jenkins工作区,然后手动执行命令,一切都会按预期工作:

The SonarQube Scanner has finished
12:28:23.407  Creating a summary markdown file...
12:28:23.411  Analysis results: http://localhost:9000/dashboard/index/eGate
12:28:23.411  Post-processing succeeded.

有什么提示如何调试吗? 如果需要,我可以提供其他日志和信息。

我可以解决这个问题。 我不是100%满意的,但是我可以通过使用完整的绝对路径调用SonarQube.Scanner.MSBuild.exe和MSBuild.exe来完成这项工作:

"C:\sonarqube\bin\SonarQube.Scanner.MSBuild.exe" begin /k:"eGate" /v:"%SVN_REVISION /d:sonar.login="%SONAR_AUTH_TOKEN%"
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /property:Configuration=AutoBuild /t:Rebuild
"C:\sonarqube\bin\SonarQube.Scanner.MSBuild.exe" end /d:sonar.login="%SONAR_AUTH_TOKEN%"

但是我不知道为什么会这样,但是从%PATH%env调用它们却没有。 真的很奇怪

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM