Difficulty running task: SonarQubeAnalyze@5

Good morning, dear

When trying to run the task on azure devops I am facing the following problem “##[error]No agent found in pool Default01 which satisfies the specified demands: java, Agent.Version -gtVersion 2.181.2”.

  • I’m using a Windows Server 2019 self-hosted agent, and I have the Java environment variable “JAVA_HOME_17_X64” .
  • I’m using Azure Devops Server, and I’m using Sonarqube 5.15.0 extension
  • I’m using version 9.9 of sonarqube.
    Below I presente my pipeline configuration


  • master

name: Default01

solution: ‘**/*.sln’
buildPlatform: ‘Any CPU’
buildConfiguration: ‘Release’


  • task: SonarQubePrepare@5
    SonarQube: ‘Service SonarQube’
    scannerMode: ‘CLI’
    configMode: ‘file’

  • task: PowerShell@2
    displayName: ‘Restore packages and build solution’
    targetType: ‘inline’
    script: |
    yarn --verbose
    failOnStderr: false

  • task: SonarQubeAnalyze@5
    jdkversion: ‘JAVA_HOME_17_X64’

Hi @Edson_Mendes - welcome to the community.

Check that your agent is actually showing java as a Capability in the Azure DevOps portal (see the MS docs for more info).

Depending on how/where you installed Java, the Microsoft build agent might not automatically detect it. Setting JAVA_HOME_17_X64 as an environment variable won’t automatically add java as a capability, and if Azure DevOps server thinks the machine does not have the java capability it won’t allocate Sonar analysis jobs to it.

If you have made recent changes to the setup of the build agent you might need to restart the build agent process so that it discovers new capabilities.

If java isn’t being detected, you could just add it as a user-defined capability. Provided it is installed correctly and locatable by the Azure DevOps task, it should work.