Integration with Azure DevOps fails

We can’t get SonarCloud working in a Azure DevOps build pipeline. It works for other projects, but on this particular one the Run Code Analysis step ends up in an error:

ERROR: Error during SonarQube Scanner execution
ERROR: Unable to load component class org.sonar.scanner.scan.filesystem.ProjectFileIndexer
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.FileIndexer
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.MetadataGenerator
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.filesystem.StatusDetection
ERROR: Caused by: Unable to load component class org.sonar.scanner.scm.ScmChangedFiles
ERROR:
The SonarQube Scanner did not complete successfully
20:28:51.607 Post-processing failed. Exit code: 1
D:\a_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.6.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 1

Hi again @michaelm ;),

From the debug logs you sent to me privately, here is the interesting part of the error:

Caused by: java.lang.NullPointerException
	at org.eclipse.jgit.lib.ObjectIdOwnerMap.get(ObjectIdOwnerMap.java:138)
	at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:888)
	at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:800)
	at org.sonarsource.scm.git.GitScmProvider.prepareTreeParser(GitScmProvider.java:196)
	at org.sonarsource.scm.git.GitScmProvider.branchChangedFiles(GitScmProvider.java:90)
	at org.sonar.scanner.scm.ScmChangedFilesProvider.loadChangedFilesIfNeeded(ScmChangedFilesProvider.java:70)

I don’t think you are using shallow clone (we are detecting it and should log a warning) but could you confirm?

We are using “Shallow fetch” option with Depth = 1. I assume it is the same thing?

Probably yes. Strange you don’t see a warning about that. Now I’m thinking of it, the detection of shallow clone is probably only done during the blame phase, which happen later.

Can you try to disable shallow clone and see if it solves your issue?