SonarScanner for .NET v7.1 JRE doesn't work

In the Release Notes for v7.0.0, it is specified that the host machine doesn’t need to have a JRE installed any longer.

I’ve tried building a dotnet project from within a build script that is run inside a docker container (mcr.microsoft.com/dotnet/sdk:8.0) and scanning it with the SonarScanner for .NET.

These are the relevant lines from the build script (similar to the example from the SonarScanner for .NET homepage):

dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"$3" /d:sonar.token="$2" /d:sonar.host.url="$1" 
dotnet build --no-incremental "<redacted>" -c Release -o /app
dotnet sonarscanner end /d:sonar.token="$2"

Installation works, and during execution, the logs show that $1, $2 and $3 are replaced with proper values. The dotnet build step even shows Sonar outputs like “Sonar: (.csproj) Project processed successfully”

But finally, when calling “dotnet sonarscanner end”, I get the following error message:

54.42 Time Elapsed 00:00:46.91
55.32 SonarScanner for MSBuild 7.0
55.32 Using the .NET Core version of the Scanner for MSBuild
55.40 Post-processing started.
55.55 Calling the SonarScanner CLI...
55.56 Could not find 'java' executable in JAVA_HOME or PATH.
55.57 The SonarScanner did not complete successfully
55.57 14:46:20.065  Post-processing failed. Exit code: 1

I can fix this by manually installing a JRE using apt-get in my build script, but I thought this was rendered obsolete by v7.0? Am I missing something here?

I have also tried installing v7.0 instead of 7.1, but the error persists.

Hey there.

What version of SonarQube are you connecting to? It will need to be v10.6 in order to take advantage of JRE auto-provisioning.

Thanks Colin, I didn’t know this. Currently, we are on a lower version.

1 Like

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