Versions used: SonarCloud with Azure DevOps
We recently migrated from SonarQube to SonarCloud. Some of our projects contain specific modules which each have their own SonarCloud project. These modules would be configured using a sonar-project.properties file, like so:
\Backend \Web \Application.Web.sln \sonar-project.properties
Using SonarQube, we could configure the ‘Prepare analysis’ task to point to this Settings File and this would work fine. In SonarCloud we used the same setting:
This would fail with the following error:
ERROR: Error during SonarQube Scanner execution ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey ERROR: ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging. E:\Buildagent\agent4\_work\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.6.0\sonar-scanner\bin\sonar-scanner.bat failed with return code: 1
Upon investigation it seems the SonarCloud ‘Prepare analysis’ task disregards the Settings File parameter and looks for a
sonar-project.properties in the root directory instead. Since that file doesn’t exist, it cannot find the project key. If I add a dummy
sonar-project.properties with a project key to the root directory, it reads that file and not the file we specified.
Our only option is to move the
sonar-project.properties contents to Advanced -> Additional parameters, but this is exactly what we don’t want, since it’s no longer in source control. Could this be fixed?
Somewhat similar bug report: Azure DevOps SonarCloud task scanner ignores manual configuration