We are getting a problem where SonarCloud is not able to perform an analysis on PR builds because it believes the “develop” branch is missing in refs/heads or refs/remotes. I’ve verified with git show-refs that these branchs do in fact exist locally. This has been working in the current tool configuration up until last month. We’ve been chasing this down with Teamcity folks for a couple weeks to no avail. We are setting the “teamcity.git.fetchAllHeads” to force teamcity to pull the entire repo down as that was the culprit a few years ago when we ran into a similar problem trying to run gitversion tooling.
Below are our specs and command line usage. Any others getting similar behavior or can spot what might have been causing this?
ALM = Bitbucket Cloud
CI = Teamcity 2024.03
OS = Linux ubuntu 22
Scanner: dotnet-sonarscanner 6.2
Scanner Command: /root/.dotnet/tools/dotnet-sonarscanner begin /d:sonar.host.url=“https://sonarcloud.io” /d:sonar.verbose=true /d:sonar.token=“*" /d:project.home=. /k:“project” /n:“name” /v:“build1” /d:sonar.cs.dotcover.reportsPaths=“coverage.html” /d:sonar.cs.nunit.reportsPaths=“nunit-results.xml” /o:someproject /d:sonar.exclusions="**/.java,**/.xml,**/.xsd” /d:sonar.pullrequest.base=“develop” /d:sonar.pullrequest.branch=“some-feature-branch” /d:sonar.pullrequest.key=43 /d:sonar.pullrequest.bitbucketcloud.owner=***** /d:sonar.pullrequest.provider=bitbucketcloud /d:sonar.pullrequest.bitbucketcloud.repository=*****
And here is the portion of the build that teamcity performs to set up the git clone environment:
/usr/bin/git init --initial-branch=main
/usr/bin/git config core.sparseCheckout true
/usr/bin/git config http.sslCAInfo
/usr/bin/git show-ref
/usr/bin/git -c core.askpass=/somepassfile -c credential.helper= -c credential.helper=/credhelper.sh fetch --progress --recurse-submodules=no origin +refs/heads/:refs/remotes/origin/
/usr/bin/git log -n1 --pretty=format:%H%x20%s –
/usr/bin/git branch
/usr/bin/git branch --create-reflog --track some-branch refs/remotes/origin/some-branch
/usr/bin/git update-ref refs/heads/some-branch
/usr/bin/git -c core.askpass=/somepassfile -c credential.helper= -c credential.helper=/credhelper.sh checkout -q -f some-branch
/usr/bin/git clean -f -d -x