Could not find ref 'refs/heads/master' in refs/heads, refs/remotes/upstream or refs/remotes/origin

Hi,

I’m getting the warning below when running SonarQube from within a Docker-container using Azure DevOps.

Could not find ref ‘refs/heads/master’ in refs/heads, refs/remotes/upstream or refs/remotes/origin
You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.

When building the Docker container I pass the arguments at build time

docker build \
  --build-arg sq_pr_branch=/d:sonar.pullrequest.branch=refs/heads/<branch> \
  --build-arg sq_pr_key=/d:sonar.pullrequest.key=<key> \
  --build-arg sq_pr_base=/d:sonar.pullrequest.base=refs/heads/master \
  -f test/Test.Dockerfile -t <container> .

We’re running SonarQube Developer Edition Version 8.6 (build 39681)

Thanks

Hi,
The SonarQube Scanner uses git to detect what code was changed in the pull request. For that, it needs local access to the target of the pull request, which is master in your case.
Make sure that master is fetched before running the scanner.