We are including SonarCloud into our organization in Azure Devops. Followed process shown in SonarCloud UI to include steps for code analysis in yaml python pipeline. The pipeline runs fine without sonarcloud code analysis step but fails when we enable it in yaml pipeline step. PFB pipeline structure and error message.
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
# Control which branches have CI triggers:
trigger:
- branchname
# To trigger the build/deploy only after a PR has been merged:
pr: none
stages:
- stage: deploy
jobs:
- job: sync__via_vm
pool:
name: $(POOL-NAME)
steps:
- checkout: self
fetchDepth: 0
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'xxxx'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'xxxx'
cliProjectName: 'xxxx'
cliSources: '.'
- script: |
xxxxxxxxxxxxxxxxxxx
- task: SonarCloudAnalyze@1
condition: succeededOrFailed()
# inputs:
# jdkversion: 'JAVA_HOME'
# - task: SonarCloudAnalyze@1
# inputs:
# jdkversion: 'JAVA_HOME_11_X64'
- task: SonarCloudPublish@1
condition: succeededOrFailed()
inputs:
pollingTimeoutSec: '300'
The pipeline fails at SonarCloudAnalyze@1 step with below error. Is there a separate analyzer for python as task only give option to add java as home.
2023-06-15T21:21:23.5269350Z ##[section]Starting: SonarCloudAnalyze
2023-06-15T21:21:23.5280113Z ==============================================================================
2023-06-15T21:21:23.5280512Z Task : Run Code Analysis
2023-06-15T21:21:23.5280791Z Description : Run scanner and upload the results to the SonarCloud server.
2023-06-15T21:21:23.5281107Z Version : 1.40.0
2023-06-15T21:21:23.5281290Z Author : sonarsource
2023-06-15T21:21:23.5281930Z 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-06-15T21:21:23.5282585Z ==============================================================================
2023-06-15T21:21:23.7395992Z [command]/myagent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner
2023-06-15T21:21:23.7649759Z ##[error]which: no java in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
2023-06-15T21:21:23.7671871Z which: no java in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
2023-06-15T21:21:23.7674280Z Could not find 'java' executable in JAVA_HOME or PATH.
2023-06-15T21:21:23.7697993Z ##[error]The process '/myagent/_work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.40.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-06-15T21:21:23.7745594Z ##[section]Finishing: SonarCloudAnalyze