Having problems with Dot.NET Core project and Java in my Azure agent to execute SonarCloud Analisis

Hi, as the title explains I’m having problems running the pipeline with .Net Core and SonarCloud

  • ALM used : Azure DevOps
  • CI system used: Azure DevOps
  • Languages of the repository: C# .NET Core

My pipeline:

  • master
    pool: ‘Servers CI’

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


  • task: UseDotNet@2
    displayName: ‘Install .NET Core SDK’
    version: 3.1.x
    performMultiLevelLookup: true

  • task: SonarCloudPrepare@1
    SonarCloud: ‘Sonarcloud SecCert’
    organization: ‘XXXXXXX’
    scannerMode: ‘MSBuild’
    projectKey: ‘XXXXXXXXXX’
    projectName: ‘SecCert’

  • task: DotNetCoreCLI@2
    displayName: ‘Build solution’
    command: ‘build’
    projects: ‘**/*.sln’
    feedsToUse: ‘select’

  • task: ReviewApp@0
    resourceName: ‘SonarSec’

  • task: SonarCloudAnalyze@1
    displayName: ‘Run SonarCloud analysis’

  • task: SonarCloudPublish@1
    pollingTimeoutSec: ‘300’

The error happens at the moment of running the task: SonarCloudAnalyze@1 and this is literally the result:

  1. ERROR: JAVA_HOME not found in your environment, and no Java executable present in the PATH.
    Please set the JAVA_HOME variable in your environment to match the location of your Java installation, or add “java.exe” to the PATH

##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]18:51:48.442 Post-processing failed. Exit code: 1
18:51:48.442 Post-processing failed. Exit code: 1
##[error]The process ‘C:\Agente Azure_work_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.20.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe’ failed with exit code 1
Finishing: Run SonarCloud analysis

The real problem is that JAVA is installed in the server used for the process (C:\Program Files\Java\jdk-16.0.1\bin) and the variables Path an JAVA_HOME are well explained into the system variables, and also into the capabilities of the agent.

Any suggestion will be appreciated.
Thanks in advance.

Hi @mauro-maulini66712

Can you try to add the path “C:\Program Files\Java\jdk-16.0.1\bin” into a capabitlity of your agent called “java” ?


Hi Mickaël.
The path “C:\Program Files\Java\jdk-16.0.1\bin” was already added to the capabilities of the agent, and in the server those are at the same time in the “Path” and in the “JAVA_HOME” server variables. I just added earlier because without them the task of SonarCloudAnalyzer not even starts. Now is starting and it´s not finding JAVA again.

Any other idea?

Thanks a lot for your time.

Maybe a dumb remark, have you put the capability with JAVA or java name ? Not sure it’s case-sensitive, but might worth checking.

Hi Mickaël.
The problem was solved changing the path for the JAVA_HOME variable to just “C:\Program Files\Java\dk-16.0.1” , removing the “\bin” from it.

Thank you for your help.

1 Like

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