Azure Devops SonarCloud Python yaml Pipeline failing

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:

# Control which branches have CI triggers:
- branchname
# To trigger the build/deploy only after a PR has been merged:
pr: none

- stage: deploy
  - job: sync__via_vm
      name: $(POOL-NAME)
    - checkout: self
      fetchDepth: 0
    - task: SonarCloudPrepare@1
        SonarCloud: 'SonarCloud'
        organization: 'xxxx'
        scannerMode: 'CLI'
        configMode: 'manual'
        cliProjectKey: 'xxxx'
        cliProjectName: 'xxxx'
        cliSources: '.'
    - script: |
    - task: SonarCloudAnalyze@1
      condition: succeededOrFailed()
#      inputs:
#        jdkversion: 'JAVA_HOME'
#    - task: SonarCloudAnalyze@1
#      inputs:
#        jdkversion: 'JAVA_HOME_11_X64'
    - task: SonarCloudPublish@1
      condition: succeededOrFailed()
        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](
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


You said you followed directions in the SonarCloud UI for setting up analysis. Could you point me to them, please? Either with a path through the UI or a link?

Regarding the error, Java is required to run analysis, so as described in the docs, you’ll need to make sure it’s available on the build agent:

  1. If you are self-hosting the build agents, check that at least the minimal version of Java supported by SonarCloud is installed. In addition, make sure the appropriate build tools are installed on the agent for the type of project you are analyzing. For example, .NET Framework v4.6+/NET Core 2.0+ if building using MSBuild, Maven for Java projects, etc.


Please find link below. Please let me know if any other details is needed from my side.
buy-rms-airflow - FBSAST (


Thanks for the link. Unfortunately it doesn’t work for me; I don’t have permissions to it.

Going back to your original post, the error indicates that you don’t have Java installed on the build agent. That’s a requirement for analysis. I asked for a pointer to the instructions you were working from to figure out where the misinformation or misunderstanding was, and unfortunately, I won’t be able to track that down.

But you’ll still need to install Java 11 on your build agent.


I had installed Java 11 in the self-hosted linux agent but had not updated JAVA_HOME in $PATH. Once done, pipeline ran fine with all 3 Sonarcloud tasks ( Prepare, run and publish ). Hence, closing ticket.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.