Gitlab CI 管道 SonarQube msbuild 错误 ArgumentNullException: 值不能为空

Gitlab CI pipeline SonarQube msbuild error ArgumentNullException: Value cannot be null

有没有人熟悉这个错误以及如何解决它?我正在使用 Sonarqube Scanner 2.3.1 和 msbuild 12.0。该项目是4.5框架。

Time Elapsed 00:00:39.12
$ SonarQube.Scanner.MSBuild.exe end
SonarQube Scanner for MSBuild 2.3.1
Default properties file was found at C:\SonarQube\bin\SonarQube.Analysis.xml
Loading analysis properties from C:\SonarQube\bin\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to 'Debug'
Post-processing started.
11:00:26.108  Using environment variables to determine the download directory...
11:00:26.188  11:00:26.188  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
11:00:26.191  Loading the SonarQube analysis config from F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube\conf\SonarQubeAnalysisConfig.xml
11:00:26.191  Not running under TeamBuild
11:00:26.191  Analysis base directory: F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube
Build directory: 
Bin directory: F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube\bin
Config directory: F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube\conf
Output directory: F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube\out
Config file: F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube\conf\SonarQubeAnalysisConfig.xml
Generating SonarQube project properties file to F:\Gitlab-Runner\buildsd3a7e33\folder\folder\folder\.sonarqube\out\sonar-project.properties

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at SonarQube.Common.ListPropertiesProvider.TryGetProperty(String key, Property& property)
   at SonarQube.Common.AggregatePropertiesProvider.TryGetProperty(String key, Property& property)
   at SonarQube.Common.AggregatePropertiesProvider.GetAllProperties()
   at SonarScanner.Shim.PropertiesFileGenerator.GetAnalysisProperties(AnalysisConfig config)
   at SonarScanner.Shim.PropertiesFileGenerator.GenerateFile(AnalysisConfig config, ILogger logger, IRoslynV1SarifFixer fixer)
   at SonarScanner.Shim.SonarScannerWrapper.Execute(AnalysisConfig config, IEnumerable`1 userCmdLineArguments, ILogger logger)
   at SonarQube.TeamBuild.PostProcessor.MSBuildPostProcessor.InvokeSonarScanner(IAnalysisPropertyProvider cmdLineArgs, AnalysisConfig config)
   at SonarQube.TeamBuild.PostProcessor.MSBuildPostProcessor.Execute(String[] args, AnalysisConfig config, ITeamBuildSettings settings)
   at SonarQube.Bootstrapper.BootstrapperClass.PostProcess()
   at SonarQube.Bootstrapper.BootstrapperClass.Execute()
   at SonarQube.Bootstrapper.Program.Execute(String[] args, ILogger logger)
   at SonarQube.Bootstrapper.Program.Main(String[] args)
ERROR: Job failed: exit status 3762504530

问题是由于 属性 称为 sonar.analysis.mode 被设置为等于 "issues"。

永远不要手动使用问题模式,因为它仅由工具使用。 设置你的 sonar.analysis.mode=[preview/publish] (发布是默认设置,因此您根本不需要设置 属性 如果这是您想要的。)