SonarCloudPrepare@3 scanner in CLI mode fails in version 3.2.0

Template for a good new topic, formatted with Markdown:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner command used when applicable:
- task: SonarCloudPrepare@3
  inputs:
	SonarCloud: 'SonarCloud'
	organization: 'XXXX'
	scannerMode: 'CLI'
	configMode: 'manual'
	cliProjectKey: 'XXXX'
	cliProjectName: 'XXXX'
	cliSources: 'XXXX'
	cliProjectVersion: "$(VersionMajorNumber).$(VersionMinorNumber).$(VersionPatchNumber).$(VersionBuildNumber)"
	extraProperties: |
	  sonar.exclusions=**/XXXX.json
	  sonar.projectBaseDir=$(Build.SourcesDirectory)/$(workingDirectory)

- task: SonarCloudAnalyze@3
  • Languages of the repository: JavaScript
  • Error observed
Starting: 💂‍♂️ Sonar - Analyze
==============================================================================
Task         : Run Code Analysis
Description  : Run scanner and upload the results to SonarQube Cloud.
Version      : 3.2.0
Author       : sonarsource
Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
==============================================================================
/agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.2.0/sonar-scanner/bin/sonar-scanner
10:28:00.337 INFO  Scanner configuration file: /agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.2.0/sonar-scanner/conf/sonar-scanner.properties
10:28:00.352 INFO  Project root configuration file: NONE
10:28:00.377 INFO  SonarScanner CLI 7.1.0.4889
10:28:00.379 INFO  Java 17.0.14 Ubuntu (64-bit)
10:28:00.379 INFO  Linux 6.8.0-1020-azure amd64
10:28:00.464 INFO  User cache: /home/AzDevOps/.sonar/cache
10:28:01.735 INFO  Communicating with SonarQube Cloud
10:28:01.736 INFO  JRE provisioning: os[linux], arch[x86_64]
10:28:05.757 INFO  Starting SonarScanner Engine...
10:28:05.758 INFO  Java 17.0.11 Eclipse Adoptium (64-bit)
10:28:06.611 INFO  Load global settings
10:28:07.306 INFO  Load global settings (done) | time=696ms
10:28:07.317 INFO  Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
10:28:07.456 INFO  Loading required plugins
10:28:07.457 INFO  Load plugins index
10:28:07.620 INFO  Load plugins index (done) | time=163ms
10:28:07.621 INFO  Load/download plugins
10:28:07.701 INFO  Load/download plugins (done) | time=80ms
10:28:08.055 INFO  Found an active CI vendor: 'Azure DevOps'
10:28:08.064 INFO  Load project settings for component key: 'XXXXX'
10:28:08.318 INFO  Load project settings for component key: 'XXXXX' (done) | time=254ms
10:28:08.325 INFO  Process project properties
##[error]10:28:08.331 ERROR Invalid value of sonar.sources for XXXXX
10:28:08.331 ERROR Invalid value of sonar.sources for XXXXX
##[error]10:28:08.338 ERROR The folder 'APP_DIR' does not exist for 'XXXXX' (base directory = /agent/_work/5/s/APP_DIR)
10:28:08.338 ERROR The folder 'APP_DIR' does not exist for 'XXXXX' (base directory = /agent/_work/5/s/APP_DIR)
10:28:08.674 INFO  EXECUTION FAILURE
10:28:08.675 INFO  Total time: 8.430s
##[error][ERROR] SonarQube Cloud: Error while executing task Analyze: The process '/agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/3.2.0/sonar-scanner/bin/sonar-scanner' failed with exit code 3

  • Potential workaround

it was working until yesterday on version 3.1.1. After downgrading tasks in the pipeline to 3.1.1 started works.

Workaround

- task: SonarCloudPrepare@3.1.1
  inputs:
	SonarCloud: 'SonarCloud'
	organization: 'XXXX'
	scannerMode: 'CLI'
	configMode: 'manual'
	cliProjectKey: 'XXXX'
	cliProjectName: 'XXXX'
	cliSources: 'XXXX'
	cliProjectVersion: "$(VersionMajorNumber).$(VersionMinorNumber).$(VersionPatchNumber).$(VersionBuildNumber)"
	extraProperties: |
	  sonar.exclusions=**/XXXX.json
	  sonar.projectBaseDir=$(Build.SourcesDirectory)/$(workingDirectory)

- task: SonarCloudAnalyze@3.1.1
1 Like

We found a workaround in Setting sonar.projectBaseDir works differently in SonarCloudPrepare@3 than in SonarCloudPrepare@2 - #6 by benjamin.raymond

- task: SonarCloudPrepare@3
  inputs:
	SonarCloud: 'SonarCloud'
	organization: 'XXXX'
	scannerMode: 'CLI'
	configMode: 'manual'
	cliProjectKey: 'XXXX'
	cliProjectName: 'XXXX'
	# cliSources: 'XXXX' ### - remove this line
	cliProjectVersion: "$(VersionMajorNumber).$(VersionMinorNumber).$(VersionPatchNumber).$(VersionBuildNumber)"
	extraProperties: |
	  sonar.sources=$(Build.SourcesDirectory)/$(workingDirectory) # - add this line
	  sonar.exclusions=**/XXXX.json 
	  sonar.projectBaseDir=$(Build.SourcesDirectory)/$(workingDirectory)

- task: SonarCloudAnalyze@3