We are also having both of these problems and I am curious about a solution. I have been able to identify something that may be contributing to the issue, but I have not yet found a solution:
Jenkins BitBucket Server integration enables “PR discovery” in Jenkins, which creates jenkins specific PR “branches”. These are virtual branches in that they only exist for the life of the PR and only inside of Jenkins. The byproduct of this is that Jenkins will, under the hood, do some merging shenanigans some times that will change the commit ID. For example, here is a recent error we got:
Failed to create Bitbucket Server Quality Report for commit SHA '0922d2f...'
The PR has only one commit which is
If I look at the Jenkins logs, I can see how Sonar is picking up the
0922d2f... commit from this part of the Jenkins PR build log:
Merging remotes/upstream/integration commit d9119ca... into PR head commit 366e037906c...
> git config core.sparsecheckout # timeout=10
> git checkout -f 366e037906c...
> git merge d9119ca... # timeout=10
Merge succeeded, producing 0922d2f...
Checking out Revision 0922d2f... (PR-73)
As you can see, it does some git shenanigans to create a PR specific commit based on the commit from the actual PR for execution in Jenkins. This appears to be what is causing the SHA disconnect, at least from what I can see. Unfortunately, I don’t have a solution (I am taking ideas!).
Separately, we are also seeing the other warning, which we also don’t have a solution for, so would love some feedback there as well.
Could not find ref ‘master’ in refs/heads or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.