Our documentation about pull request analysis parameters should help you. When doing the analysis of a pull request you should specify the sonar.pullrequest.base parameter to tell SonarCloud what is the target branch of this PR.
As long as we update the branch in Sonar.pullrequest.branch, its fine. But the pull request will be created for every branch during short intervals and mentioning the branch and changing the branch name in in Sonar.pullrequest.branch always is tough.
Is there any possibility to mention in the parameter to pick the branch automatically from where the PR is created ?
I guess that in the payload of the Bitbucket webhook that triggers the Jenkins job you should have the PR id and the target of the PR so that you can set it dynamically from there when triggering the job.
I don’t know which webhook you use exactly, but for example, looking at the pull request event payload from Bitbucket we can see that there is a destination.branch field which is probably what you should use as a value for the sonar.pullrequest.base parameter when you start the scanner job.
Yes, after mentioning the required sonar.pullrequest.base, sonar.pullrequest.branch, sonar.pullrequest.key parameters, we can able to display the name and coverage of the PR’s in sonarcloud UI :
But every time whenever a PR is created in bitbucket, we need to manually change the above pull requests parameters in Jenkins under execute scanner properties. Can this be automated without any manual change every time? So that the Jenkins itself should pick the pull requests parameters automatically and post it as in the mentioned screenshot?