Sonarcloud integration with .net based pipeline throws error at "Run code analysis" step

Hello community members,

I am trying to integrate Sonarcloud with .net based Azdevops pipeline . I have created service connection & ingtegrated both the environment. I have included 3 tasks- “Prepare Analysis On Sonarcloud” after Nuget restore , “Run Code analysis” & "Publish Gate Results"tasks after including Visual Studio build solution task.
The pipeline fails at Run code analysis -“Error During SOnarscanner execution”.

Kindly help in here . Shall we do some configurations on the agent host.

Hi,

Welcome to the community!

Can we have the full analysis log, starting from the analysis command? “Error During Sonarscanner execution” isn’t much to go on.

 
Ann

Sure G Ann,

I am using an Azure Devops pipeline where we have restore nuget , prepare analysis for sonar, build desktop application, Run code analysis task & Publish quality gate result.

Here’s the log for “Run Code Analysis” task-
2022-12-15T18:37:34.0730916Z ##[section]Starting: Run Code Analysis
2022-12-15T18:37:34.0820096Z ==============================================================================
2022-12-15T18:37:34.0820433Z Task : Run Code Analysis
2022-12-15T18:37:34.0820708Z Description : Run scanner and upload the results to the SonarCloud server.
2022-12-15T18:37:34.0820991Z Version : 1.33.1
2022-12-15T18:37:34.0821168Z Author : sonarsource
2022-12-15T18:37:34.0821755Z Help : Version: 1.33.1. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

More Information
2022-12-15T18:37:34.0822638Z ==============================================================================
2022-12-15T18:37:35.1017742Z [command]C:\Windows\system32\cmd.exe /D /S /C “C:\agent_work_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.33.1\sonar-scanner\bin\sonar-scanner.bat”
2022-12-15T18:37:35.1316707Z
2022-12-15T18:37:35.1318456Z ERROR: JAVA_HOME exists but does not point to a valid Java home
2022-12-15T18:37:35.1319100Z folder. No “\bin\java.exe” file can be found there.
2022-12-15T18:37:35.1319425Z
2022-12-15T18:37:35.1496451Z ##[error]The process ‘C:\agent_work_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.33.1\sonar-scanner\bin\sonar-scanner.bat’ failed with exit code 1
2022-12-15T18:37:35.1561434Z ##[section]Finishing: Run Code Analysis

I am using a self hosted agent with Java JDK 19 installed & JAVA_HOME pointing to JDK source files.

Regards,
Divya M

Hi Divya,

Analysis needs Java to run and this error is telling you that the process isn’t finding it:

You’ll need to make sure that Java is available on the build agent and that the $JAVA_HOME env_var is set to point to it, such that $JAVA_HOME/bin/java.exe exists.

 
HTH,
Ann