which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): Community Edition, Version 9.9 (build 65466)
how is SonarQube deployed: installed from zip
what are you trying to achieve: run SonarQube .NET analysis
what have you tried so far to achieve this: it worked, stopped working after SonarScanner for .NET upgrade. Currently using sonar-scanner-4.8.0.2856 for .NET 5
I use SonarQube .NET Scanner on TeamCity. The analysis has 3 steps:
begin the analysis: dotnet C:\SonarQubeDotNetScanner\SonarScanner.MSBuild.dll begin /k:“ProjectKey” /d:sonar.login=“3fbxxxxxxxxxxxxca9fe1e30e3681a2ad5dee”
build the solution with MSBuild
end the analysis: dotnet C:\SonarQubeDotNetScanner\SonarScanner.MSBuild.dll end /d:sonar.login=“3fbxxxxxxxxxxxxca9fe1e30e3681a2ad5dee”
So far, everything worked fine. Few weeks ago I updated SonarScanner for .NET to version 4.8.0.2856 and soon after the analysis end step in TeamCity fails with the following error message:
ERROR: Error during SonarScanner execution
ERROR: Not inside a Git work tree: C:\TeamCity\buildAgent\work\d2e70520a04078d9
It has always worked and we didn’t change anything related to git repo settings.
The fact is that the workspace folder on the machine doesn’t have .git folder inside, but it never has had it and it worked.
dotnet C:\SonarQubeDotNetScanner\SonarScanner.MSBuild.dll begin /k:“ProjectKey” /d:sonar.login=“3fbxxxxxxxxxxxxca9fe1e30e3681a2ad5dee” /d:sonar.projectBaseDir=%teamcity.build.checkoutDir%
but it doesn’t help, I’m getting the same error:
ERROR: Not inside a Git work tree: C:\TeamCity\buildAgent\work\d2e70520a04078d9
I tried adding this parameter /d:sonar.projectBaseDir=%teamcity.build.checkoutDir%* to the end step, as this step actually fails, but then I got the following error:
This setting is not valid in the "end" phase in this version of the C# plugin: sonar.projectBaseDir
Hi Colin,
actually, the package I downloaded is called “sonar-scanner-msbuild-5.13.0.66756-net5.0”, so it is v5.13. What mislead me is that the folder inside is called “sonar-scanner-4.8.0.2856”. So this is the version I am using.
Now you mentioned upgrading the SonarScanner for .NET, did you also upgrade SonarQube lately? Or has it always been working before on SonarQube v9.9 specifically?
Actually, I’ve also upgraded SonarQube recently. The current version is Community EditionVersion 9.9 (build 65466)
However, after upgrading only SonarQube, it worked fine.
After changing it, the .git folder is back and the analysis seems to work again. Thanks for that tip!
Anyway, we have never had this .git folder there, so something must have changed in recent SonarQube/SonarScanner versions that it started to be a problem for the analysis.
I noticed that now, the automatic issues assignation works while it didn’t work before. Apparently, when it was enabled in SonarQube, but there was no .git folder, it was simply ignored and not performed. Now when it’s enabled, but .git folder is not present, it results in an error during analysis.