SonarQube MSBuild 与 Jenkins 的集成失败,在命令行上工作正常
SonarQube MSBuild integration failed with Jenkins, works fine on command line
我正在用 sonarqube 分析我的 .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“SonarQube Scanner for MSBuild - Begin Analysis”和“SonarQube Scanner for MSBuild - End Analysis”构建步骤,但它们失败并显示以下错误消息:
The SonarQube MSBuild integration failed: SonarQube was unable to
collect the required information about your projects. Possible causes:
- The project has not been built - the project must be built in between the begin and end steps
- An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
- The begin, build or end steps have not all been launched from the same folder
我尝试了几件事,然后切换到 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
剪辑
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.0\Bin\MSBuild.exe" /property:Configuration=AutoBuild /t:Rebuild
"C:\sonarqube\bin\SonarQube.Scanner.MSBuild.exe" end /d:sonar.login="%SONAR_AUTH_TOKEN%"
但我不明白为什么会这样,但从 %PATH% 环境中调用它们却不行。真的很奇怪...
我正在用 sonarqube 分析我的 .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“SonarQube Scanner for MSBuild - Begin Analysis”和“SonarQube Scanner for MSBuild - End Analysis”构建步骤,但它们失败并显示以下错误消息:
The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects. Possible causes:
- The project has not been built - the project must be built in between the begin and end steps
- An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
- The begin, build or end steps have not all been launched from the same folder
我尝试了几件事,然后切换到 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
剪辑
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.0\Bin\MSBuild.exe" /property:Configuration=AutoBuild /t:Rebuild
"C:\sonarqube\bin\SonarQube.Scanner.MSBuild.exe" end /d:sonar.login="%SONAR_AUTH_TOKEN%"
但我不明白为什么会这样,但从 %PATH% 环境中调用它们却不行。真的很奇怪...