- versions used: SonarCloud, standalone scanner, typescript plugin
- error observed: scanner ignores the manual configuration and falls back to the sonar-project.properties
- steps to reproduce: none
- potential workaround: none found
Hi,
Using AzureDevOps with SonarCloud tasks, I have a typescript project with a modules structure:
.
|-- Tasks
| |-- Task1
| | |-- <source files>
| | `-- sonar-project.properties
| |-- Task2
| | |-- <source files>
| | `-- sonar-project.properties
| `-- Task3
| |-- <source files>
| `-- sonar-project.properties
|-- Tests
`-- sonar-project.properties
I have 2 build pipelines. The first one compiles, tests and analyzes coverage for all tasks (modules).
Using the SonarCloudPrepare task with this configuration, it works well
# prepare Sonarcloud analysis
- task: SonarCloudPrepare@1
displayName: Prepare analysis
inputs:
SonarCloud: 'SonarCloud Endpoint'
organization: my-org
scannerMode: CLI
configFile: './sonar-project.properties'
The second build pipeline is used for a specific task and it compiles, tests and analyzes coverage for a single task or module (short-live branch where the branch is named after the module, i.e. feature/TaskName)
I don’t want to rely on the sonar-project.properties file so I switch to manual configuration:
# prepare Sonarcloud analysis
- task: SonarCloudPrepare@1
displayName: Prepare analysis on SonarCloud
inputs:
SonarCloud: 'SonarCloud Endpoint'
organization: my-org
scannerMode: CLI
configMode: manual
cliProjectKey: vso.tasks
cliProjectName: vso.tasks
extraProperties: 'sonar.projectBaseDir=Tasks/Task3'
and it fails miserably, ignoring my manual config:
[command]/home/adminuser/agent03/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.5.1/sonar-scanner/bin/sonar-scanner
INFO: Scanner configuration file: /home/adminuser/agent03/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.5.1/sonar-scanner/conf/sonar-scanner.properties
Project root configuration file: /home/adminuser/agent03/_work/8/s/sonar-project.properties
INFO: SonarQube Scanner 3.2.0.1227
“But it works on my machine” and that’s (almost) true. After installing the scanner on my machine and running it from the command line C:\vso-tasks>W:\sonarscanner\bin\sonar-scanner.bat -Dsonar.projectKey=vso.tasks -Dsonar.projectBaseDir=C:\vso-tasks\Tasks\Task3 -Dsonar.sources=.
, the scanner uses the command line parameters and does not rely on my root sonar-project.properties file:
INFO: Scanner configuration file: W:\sonarscanner\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\Tasks\Task3\sonar-project.properties
INFO: SonarQube Scanner 3.2.0.1227
I tried all possible combinations with the extraProperties
but I still can’t find why the scanner ignores the sonar.projectBaseDir
parameter.