Warning when running analysis as below:
SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
We have seen where code issues are incorrectly being flagged as originating in the branch being analysed when they are pre-existing issues in the code base. We are doing a full git clone - not shallow.
I have tried setting the SCM provider manually in the project’s general settings as below
As soon as I do that the next analysis had an error saying ‘Not inside a Git work tree’.
##[error]ERROR: Error during SonarScanner execution
ERROR: Error during SonarScanner execution
##[error]ERROR: Not inside a Git work tree: /
ERROR:
ERROR: Not inside a Git work tree: /
ERROR:
##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]10:34:18.703 Post-processing failed. Exit code: 1
10:34:18.703 Post-processing failed. Exit code: 1
##[error]The process '/azp/_work/_tool/dotnet/dotnet' failed with exit code 1
Can you run an ls -la immediately before SonarQubeAnalyze to see if there is a .git folder? And, could you also run git --version to return the Git version info?
In the hope that the forum may be useful to some - the issue here was that the analysis was being performed at the wrong level when source code was checked out into the Azure DevOps pipeline.
The issue was seen in the pull-request where the path prefix was wrong (not sure why as it was working previously):
By setting sonar.projectBaseDir on the SonarCloudPrepare task to the Azure DevOps pipeline variable Build.SourcesDirectory the warning in the analysis run went away and the problem of incorrect issues being reported went too (I believe that is due to the SCM identification now working correctly).