'New Code' on feature branch being polluted with details from mainline

We run the scanner locally as part of our build. We have a Jenkinsfile (declarative pipeline). In one of the stages, we perform a “withSonarQubeEnv” that executes 'sh “mvn -T 4 -Dsonar.projectVersion={placeholderVersion} -Dsonar.branch.name={branch} org.sonarsource.scanner.maven:sonar-maven-plugin:sonar”.

Based on reading other posts, other similarly-affected people have traced their issue to “shallow-clone” issues. I don’t think that is affecting us. As part of an earlier step in the above process, we perform a “bbs_checkout” (the command Bitbucket recommends for retrieving the source code). From inspection, this appears to have a full copy of the source (not shallow), although it is a ‘detached HEAD’.

I am unsure about the results of the above merge-base command. We’ve subsequently disabled the gateway check in order to merge the PR, so my results are somewhat questionable. I don’t currently have a broken branch to look at.

  • When I go to the (old) build-environment for the broken branch and run the command, it yields the common ancestor as a 7-day old commit. The expected ancestor is 4-days old. I’ll have to dig to see why that 7-day ancestor is coming into play.
  • When I look at other (seemingly OK) branches, the above command yields the expected commit as the fork point.

I’m going to try and recreate the issue and then use the above command to see if it helps me understand it better.

I will also research why that 7-day commit (vs 4-day commit) is being returned.