Description
OpenJDK 11 and 17 are both installed via homebrew. Their paths are correctly described in their respective ENV values below. Running java at the path in terminal works as expected. However, the analyze task throws an error Could not find 'java' executable in JAVA_HOME or PATH.
Environment
- Azure DevOps Git Repository
- Azure DevOps Pipeline
- Agent version 3.220.5
- Host OS: macOS
- Ventura 13.5
- Language Analyzed: Swift
Pipeline tasks
- task: SonarCloudPrepare@1
inputs:
SonarCloud: "SonarCloud"
organization: "company"
scannerMode: "CLI"
configMode: "manual"
cliProjectKey: project
cliProjectName: iOS ActivationClient
cliSources: "Packages/common/Sources/ActivationClient/"
extraProperties: |
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
sonar.coverageReportPaths=$(Agent.TempDirectory)/ActivationClient-sonarqube-generic-coverage.xml
- task: SonarCloudAnalyze@1
inputs:
jdkversion: 'JAVA_HOME_11_X64' # also tried JAVA_HOME_17_X64 here
env:
JAVA_HOME_11_X64: '/opt/homebrew/opt/openjdk@11/bin'
JAVA_HOME_17_X64: '/opt/homebrew/opt/openjdk@17/bin'
Task log
2023-08-01T13:23:57.0582780Z ##[debug]Evaluating condition for step: 'SonarCloudAnalyze'
2023-08-01T13:23:57.0583270Z ##[debug]Evaluating: SucceededNode()
2023-08-01T13:23:57.0583430Z ##[debug]Evaluating SucceededNode:
2023-08-01T13:23:57.0583680Z ##[debug]=> True
2023-08-01T13:23:57.0583810Z ##[debug]Result: True
2023-08-01T13:23:57.0583960Z ##[section]Starting: SonarCloudAnalyze
2023-08-01T13:23:57.0588060Z ==============================================================================
2023-08-01T13:23:57.0588130Z Task : Run Code Analysis
2023-08-01T13:23:57.0588180Z Description : Run scanner and upload the results to the SonarCloud server.
2023-08-01T13:23:57.0588230Z Version : 1.40.0
2023-08-01T13:23:57.0588260Z Author : sonarsource
2023-08-01T13:23:57.0588300Z Help : Version: 1.40.0. 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/)
2023-08-01T13:23:57.0588570Z ==============================================================================
2023-08-01T13:23:58.1477240Z ##[debug]Using node path: /Users/admin/pipeline-agent/externals/node10/bin/node
2023-08-01T13:23:58.7639630Z ##[debug]agent.TempDirectory=/Users/admin/pipeline-agent/_work/_temp
2023-08-01T13:23:58.7768230Z ##[debug]loading inputs and endpoints
2023-08-01T13:23:58.7838980Z ##[debug]loading INPUT_JDKVERSION
2023-08-01T13:23:58.7923980Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2023-08-01T13:23:58.7932000Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2023-08-01T13:23:58.7935210Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2023-08-01T13:23:58.7973140Z ##[debug]loading SECRET_APPSTORECONNECTKEYCONTENT
2023-08-01T13:23:58.8003550Z ##[debug]loading SECRET_HOSTUSERPASSWORD
2023-08-01T13:23:58.8004370Z ##[debug]loading SECRET_MATCHGITPASSPHRASE
2023-08-01T13:23:58.8004990Z ##[debug]loading SECRET_SSHPASSPHRASE
2023-08-01T13:23:58.8005510Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2023-08-01T13:23:58.8006050Z ##[debug]loading SECRET_APPSTORECONNECTKEYISSUERID
2023-08-01T13:23:58.8006530Z ##[debug]loading SECRET_APPSTORECONNECTKEYID
2023-08-01T13:23:58.8007030Z ##[debug]loading SECRET_SONARQUBE_ENDPOINT
2023-08-01T13:23:58.8008600Z ##[debug]loaded 12
2023-08-01T13:23:58.8020160Z ##[debug]Agent.ProxyUrl=undefined
2023-08-01T13:23:58.8020710Z ##[debug]Agent.CAInfo=undefined
2023-08-01T13:23:58.8020920Z ##[debug]Agent.ClientCert=undefined
2023-08-01T13:23:58.8021100Z ##[debug]Agent.SkipCertValidation=undefined
2023-08-01T13:23:58.8496290Z ##[debug]jdkversion=JAVA_HOME_11_X64
2023-08-01T13:23:58.8511890Z ##[debug]SONARQUBE_SCANNER_MODE=CLI
2023-08-01T13:23:58.8512720Z ##[debug]Trying to resolve JAVA_HOME_11_X64 from environment variables...
2023-08-01T13:23:58.8514540Z ##[debug]JAVA_HOME_11_X64=/opt/homebrew/opt/openjdk@11/bin
2023-08-01T13:23:58.8514790Z ##[debug]JAVA_HOME_11_X64 was found with value /opt/homebrew/opt/openjdk@11/bin, will switch to it for Sonar scanner...
2023-08-01T13:23:58.8515020Z ##[debug]JAVA_HOME=/opt/homebrew/opt/openjdk@17/bin
2023-08-01T13:23:58.8515240Z ##[debug]set JAVA_HOME=/opt/homebrew/opt/openjdk@11/bin
2023-08-01T13:23:58.8552000Z ##[debug]Processed: ##vso[task.setvariable variable=JAVA_HOME;isOutput=false;issecret=false;]/opt/homebrew/opt/openjdk@11/bin
2023-08-01T13:23:58.8564590Z ##[debug]SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"https://sonarcloud.io/","sonar.login":***,"sonar.organization":"company","sonar.projectKey":"project","sonar.projectName":"iOS ActivationClient","sonar.projectVersion":"1.0","sonar.sources":"/Users/admin/pipeline-agent/_work/23/s/Packages/common/Sources/ActivationClient/","sonar.branch.name":"bugfix/test-jdk-env-in-pipeline-config-for-sonar","sonar.scanner.metadataFilePath":"/Users/admin/pipeline-agent/_work/_temp/sonar/36782/aca6e54e-250a-27f6-7b9f-36e998f5154c/report-task.txt","sonar.c.file.suffixes":"-","sonar.cpp.file.suffixes":"-","sonar.objc.file.suffixes":"-","sonar.coverageReportPaths":"/Users/admin/pipeline-agent/_work/_temp/ActivationClient-sonarqube-generic-coverage.xml"}
2023-08-01T13:23:58.8610260Z ##[debug]Absolute path for pathSegments: /Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0,sonar-scanner,bin,sonar-scanner = /Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner
2023-08-01T13:23:58.8750600Z ##[debug]which '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner'
2023-08-01T13:23:58.8780970Z ##[debug]found: '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner'
2023-08-01T13:23:58.8794500Z ##[debug]system.debug=True
2023-08-01T13:23:58.8797080Z ##[debug]exec tool: /Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner
2023-08-01T13:23:58.8797320Z ##[debug]arguments:
2023-08-01T13:23:58.8805020Z [command]/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner
2023-08-01T13:23:58.9427840Z Could not find 'java' executable in JAVA_HOME or PATH.
2023-08-01T13:23:58.9445120Z ##[debug]Exit code 1 received from tool '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner'
2023-08-01T13:23:58.9449730Z ##[debug]STDIO streams have closed for tool '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner'
2023-08-01T13:23:58.9638200Z ##[debug]task result: Failed
2023-08-01T13:23:58.9667500Z ##[error]The process '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-08-01T13:23:58.9671480Z ##[debug]Processed: ##vso[task.issue type=error;]The process '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-08-01T13:23:58.9672280Z ##[debug]Processed: ##vso[task.complete result=Failed;]The process '/Users/admin/pipeline-agent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-08-01T13:23:58.9700130Z ##[section]Finishing: SonarCloudAnalyze