- ALM used - Azure DevOps
- CI system used Azure DevOps
- Languages of the repository - C#
I have a .net project which is built using a private ubuntu build agent. I am using a YAML build pipeline but with the stage
- task: SonarCloudAnalyze@1 displayName: Run Sonar Cloud Code Analysis continueOnError: false
Im getting the error
msbuild/SonarScanner.MSBuild.dll end SonarScanner for MSBuild 5.13 Using the .NET Core version of the Scanner for MSBuild Post-processing started. Calling the SonarScanner CLI... Could not find 'java' executable in JAVA_HOME or PATH. ##[error]The SonarScanner did not complete successfully The SonarScanner did not complete successfully ##[error]16:50:28.171 Post-processing failed. Exit code: 1 16:50:28.171 Post-processing failed. Exit code: 1 ##[error]The process '/home/devops/myagent/_work/_tool/dotnet/dotnet' failed with exit code 1 Finishing: Run Sonar Cloud Code Analysis
I can confirm java is installed on the agent, the version is
java --version openjdk 18.104.22.168 2023-08-24 OpenJDK Runtime Environment (build 22.214.171.124+1-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 126.96.36.199+1-Ubuntu-0ubuntu120.04, mixed mode, sharing)
And the agent has the following capabilities
Java - /usr/bin/java JAVA_HOME - /usr/lib/jvm/java-17-openjdk-amd64/bin/java JDK - /usr/bin/javac
Im struggling to understand what is wrong – I can confirm that my build works when I use the azure pipelines agent so its definitely an issue with the private build agent.
Here is my yaml
- task: SonarCloudPrepare@1 inputs: SonarCloud: SonarCloud organization: $(SonarCloud_Organization) scannerMode: MSBuild projectKey: $(SonarCloud_ProjectKey) projectName: $(SonarCloud_ProjectName) - task: DotNetCoreCLI@2 displayName: .NET Build inputs: command: 'build' arguments: '--configuration $(buildConfiguration)' projects: '**/*.csproj' - task: SonarCloudAnalyze@1 displayName: Run Sonar Cloud Code Analysis continueOnError: false
Any advice on how I can resolve this?