- SonarQube Community 25.3.0.104237, .NET Scanner 7.1.1
- Deployed from zip
I’m trying to get an azure devops pipeline to run code analyses on a primarily C# codebase but I keep running into errors during the Prepare task, here is the output:
D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:Test-Project
SonarScanner for MSBuild 9.0.2
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
17:35:00.828 Updating build integration targets...
17:35:00.96 Using SonarQube v25.3.0.104237.
17:35:00.993 Fetching analysis configuration settings...
##[error]17:35:01.252 Pre-processing failed. Exit code: 1
17:35:01.252 Pre-processing failed. Exit code: 1
##[error][ERROR] SonarQube Server: Error while executing task Prepare: The process 'D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
##[error]The process 'D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: Prepare analysis on SonarQube Server
The errors are not very helpful here so I tried navigating to the directory and executing the same command, which produced this output in powershell:
D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild> .\SonarScanner.MSBuild.exe begin /k:Test-Project
SonarScanner for MSBuild 9.0.2
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
12:07:35.742 Updating build integration targets...
12:07:37.463 Organization parameter (/o:"<organization>") is required and needs to be provided!
12:07:37.465 WARNING: In version 7 of the scanner, the default value for the sonar.host.url changed from "http://localhost:9000" to "https://sonarcloud.io".
If the intention was to connect to the local SonarQube instance, please add the parameter: /d:sonar.host.url="http://localhost:9000"
12:07:37.466 Pre-processing failed. Exit code: 1
If I retry the command but add /o:"sonar"
to the end, it seems to fix the error and it ends with “Pre-processing succeeded.” but I don’t see a way to do that using the azure devops task. I tried adding things like sonar.organization="sonar"
, organization="sonar"
, /o:"sonar"
to the “Additional Properties” box but it didn’t seem to do anything.
I tried using a script in the pipeline that would just execute the working command in that same directory, it seems to work but then the Analysis task complains that the Prepare task wasn’t run.
Finally, I tried running the same script that executes the working command, and then running a Prepare task right afterwards that I let continue on failure, to see if I could trick the Analysis task into running. The Analysis task does try to run but gets an error, here is the output:
D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 9.0.2
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
##[error]11:57:12.917 SonarQube analysis could not be completed because the analysis configuration file could not be found: D:\agent\_work\24\.sonarqube\conf\SonarQubeAnalysisConfig.xml.
11:57:12.917 SonarQube analysis could not be completed because the analysis configuration file could not be found: D:\agent\_work\24\.sonarqube\conf\SonarQubeAnalysisConfig.xml.
##[error]11:57:12.917 Post-processing failed. Exit code: 1
11:57:12.917 Post-processing failed. Exit code: 1
##[error][ERROR] SonarQube Server: Error while executing task Analyze: The process 'D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
##[error]The process 'D:\agent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\7.1.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: Run Code Analysis
I guess running the command like that instead of the actual pipeline task doesn’t generate a file that it needs…
While investigating I found a few threads of people who have similar issues where the “organization” parameter is required but there is no default value for it set. These bugs seem to have been closed, but for SonarQube Cloud, not SonarQube Community:
- Azure DevOps: SonarCloud Prepare Analysis Configuration task ignores selected organization when fetching quality profiles
- Azure Devops integration with Sonarcloud - cannot find quality profile
- Scanner does not use organization when fetching QPs from SonarCloud · Issue #692 · SonarSource/sonar-scanner-msbuild · GitHub
- Support SonarCloud with organization · Issue #256 · jdamata/terraform-provider-sonarqube · GitHub