Using the latest version of Azure DevOps build pipelines and the “Prepare Analysis” step.
Unfortunately, the “Run Code Analysis” reports an error that it cannot find the sonar.projectKey.
[command]C:\Windows\system32\cmd.exe /D /S /C "D:\agent\_work\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.6.2\sonar-scanner\bin\sonar-scanner.bat"
(node:2552) Warning: Use Cipheriv for counter mode of aes-256-ctr
(node:2552) Warning: Use Cipheriv for counter mode of aes-256-ctr
(node:2552) Warning: Use Cipheriv for counter mode of aes-256-ctr
(node:2552) Warning: Use Cipheriv for counter mode of aes-256-ctr
INFO: Scanner configuration file: D:\agent\_work\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.6.2\sonar-scanner\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 12.0.1 Oracle Corporation (64-bit)
INFO: Windows Server 2016 10.0 amd64
INFO: User cache: C:\Windows\ServiceProfiles\NetworkService\.sonar\cache
INFO: SonarQube server 7.8.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=646ms
INFO: Server id: BD367519-AWHW8ct9-T_TB3XqouNu
INFO: User cache: C:\Windows\ServiceProfiles\NetworkService\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=158ms
INFO: Load/download plugins (done) | time=330ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 3.555s
INFO: Final Memory: 6M/24M
INFO: ------------------------------------------------------------------------
##[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.
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.
##[error]D:\agent\_work\_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.6.2\sonar-scanner\bin\sonar-scanner.bat failed with return code: 1
##[section]Finishing: Run Code Analysis
You’ll see above that it cannot find the project root configuration file.
However, in my “Prepare Analysis” step, I’ve got the following configuration:
Way to run analysis: Use standalone scanner Mode: Store configuration with my source code Settings file: Browser/sonar-project.properties
I’ve also tried the full project path for settings file: $(System.DefaultWorkingDirectory)/Browser/sonar-project.properties
The java exec command line (%JAVA_EXEC% -Djava.awt.headless=true %SONAR_SCANNER_DEBUG_OPTS% %SONAR_SCANNER_OPTS% -cp "%SONAR_SCANNER_HOME%\lib\sonar-scanner-cli-3.3.0.1492.jar" "-Dscanner.home=%SONAR_SCANNER_HOME%" "-Dproject.home=%PROJECT_HOME%" org.sonarsource.scanner.cli.Main %*) looks like this in the task runner logs: