Calling the SonarScanner CLI... Unhandled exception

Hello,

  • We’re on a paid plain.
  • Seeking support for guidance through this issue.
  • Confirmed that our billing is current, last payment successfully remitted 2022-06-17
  • We’ve been using SonarCloud without interruption for over a year.
  • Was working fine on Friday
  • We’re using SonarCloud with Bitucket.
  • SonarScanner for MSBuild 5.7
  • Using the .NET Core version of the Scanner for MSBuild
  • Our developers in multiple code bases are reporting that when CICD attempts to call the SonarCloud CLI, the scan fails with an unhandled exception (stack trace below).

Stack Trace

Calling the SonarScanner CLI...
Unhandled exception. System.ComponentModel.Win32Exception (13): Permission denied
   at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at SonarScanner.MSBuild.Common.ProcessRunner.Execute(ProcessRunnerArguments runnerArgs)
   at SonarScanner.MSBuild.Shim.SonarScannerWrapper.ExecuteJavaRunner(AnalysisConfig config, IEnumerable`1 userCmdLineArguments, ILogger logger, String exeFileName, String propertiesFileName, IProcessRunner runner)
   at SonarScanner.MSBuild.Shim.SonarScannerWrapper.InternalExecute(AnalysisConfig config, IEnumerable`1 userCmdLineArguments, ILogger logger, String fullPropertiesFilePath)
   at SonarScanner.MSBuild.Shim.SonarScannerWrapper.Execute(AnalysisConfig config, IEnumerable`1 userCmdLineArguments, String propertiesFilePath)
   at SonarScanner.MSBuild.PostProcessor.MSBuildPostProcessor.InvokeSonarScanner(IAnalysisPropertyProvider cmdLineArgs, AnalysisConfig config, String propertiesFilePath)
   at SonarScanner.MSBuild.PostProcessor.MSBuildPostProcessor.Execute(String[] args, AnalysisConfig config, ITeamBuildSettings settings)
   at SonarScanner.MSBuild.BootstrapperClass.PostProcess()
   at SonarScanner.MSBuild.BootstrapperClass.Execute()
   at SonarScanner.MSBuild.Program.Execute(String[] args, ILogger logger)
   at SonarScanner.MSBuild.Program.Execute(String[] args)
   at SonarScanner.MSBuild.Program.Main(String[] args)
   at SonarScanner.MSBuild.Program.<Main>(String[] args)

Hey there.

Can you test and see if reverting to v5.6 of the Scanner for .NET fixes things? We just released v5.7 and it seems there might be a bug.

1 Like

Hi Colin, thank you for your reply, I have defined the version to be 5.6 and the issue is resolved.

Worked well, thanks Colin & Anil.

Hello @caseywise

Sorry for this problem. We’ve published version 5.7.1 fixing that issue - could you please confirm it works?

If it doesn’t, please stay on 5.6 until we further investigate (and please give us your full debug logs and also the YAML file you use).

Thanks!
Andrei

Andrei_Epure, no luck

Attempted Deployment Using 5.7.1

Calling the SonarScanner CLI...
Unhandled exception. System.ComponentModel.Win32Exception (13): Permission denied

Bitbucket Pipeline Script

- export PATH_TO_UNIT_TEST_PROJECT="./test/EmailApiFacade.Tests"
- apt-get update
- apt-get install --yes openjdk-11-jre nodejs
- wget -qO- https://aka.ms/install-artifacts-credprovider.sh | bash
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool install --global dotnet-reportgenerator-globaltool
# - dotnet tool install --global dotnet-sonarscanner --version 5.6
- dotnet tool install --global dotnet-sonarscanner
- |
    dotnet sonarscanner begin \
    /k:"${BITBUCKET_REPO_SLUG}" \
    /d:sonar.login="${SONAR_TOKEN}" \
    /o:"extendedstay-website" \
    /d:"sonar.host.url=https://sonarcloud.io" \
    /d:sonar.cs.opencover.reportsPaths="test-results/**/coverage.opencover.xml"
- dotnet build .
- |
    dotnet test "${PATH_TO_UNIT_TEST_PROJECT}" \
    --logger="trx;LogFileName=unittests.trx" \
    --results-directory="test-results/" \
    --collect:"XPlat Code Coverage" \
    /p:CollectCoverage=true \
    /p:CoverletOutputFormat="opencover" \
    -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- dotnet sonarscanner end /d:sonar.login="${SONAR_TOKEN}"

Debug Logs

I’m not comfortable posting these in a public forum, happy to send in an encrypted email, can you please provide?

Hello @caseywise

As the new version was published to nuget only a short period of time before you tried again, it might be that it was still installing the 5.7.0 version of the dotnet-sonarscanner.
Other users with the same issue have reported that using the 5.7.1 version fixed the exact same problem they had.
Could you please check in the logs that you used indeed the 5.7.1 version of the dotnet-sonarscanner?

All the best,
Čaba

Hi Čaba,

  • You are correct, I did review our CICD logs, indeed the dotnet-sonarscanner version was v5.7 installed and run and again threw an exception.
  • Attempted to run again without setting the --version switch on the dotnet tool install --global dotnet-sonarscanner command.
  • Reviewed the logs and v5.7.1 did install and run without exception.

Thanks for the follow up!

Cheers,
Casey Wise

Thanks a lot @caseywise for the confirmation.

I’m going to send you a private message on this forum to better understand your pipeline setup and environment. It shouldn’t involve logs and sensitive info, still I’ll send a private message to feel safe.

The idea is that we want to add a regression test for such scenario and we first need to reproduce the problem (we currently don’t have a reproducer).

You can access the private message here: https://community.sonarsource.com/t/re-calling-the-sonarscanner-cli-unhandled-exception/66741

Cheers!
Andrei