PR Decorations not showing up in Bitbucket Server (Datacenter Edition)

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Developer Edition
    Version 10.3 (build 82913)

  • how is SonarQube deployed: zip, Docker, Helm
    Helm

  • what are you trying to achieve
    PR Decorations in Atlassian Bitbucket v7.21.4

  • what have you tried so far to achieve this
    I’ve configured the DevOps Platform Integration in SonarQube for Bitbucket and it says Quality Gate status reporting is green.

I’ve run builds using Jenkins project level job with successful scan results in SonarQube and also I see the SonarQube Gate results in Jenkins.
I’ve also checked that at the project level, the DevOps Platform Integration fields are filled in and it shows “Configuration Valid” at the bottom.

The logs for the ce show no errors:

> 2023.12.20 16:15:45 INFO  ce[AYyIAqrKbY_AZ_TlAO_1][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Webhooks | globalWebhooks=1 | projectWebhooks=0 | status=SUCCESS | time=145ms
> 2023.12.20 16:15:45 INFO  ce[AYyIAqrKbY_AZ_TlAO_1][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Pull Request decoration | status=SUCCESS | time=0ms
> 2023.12.20 16:15:45 INFO  ce[AYyIAqrKbY_AZ_TlAO_1][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Report branch Quality Gate status to devops platforms | status=SUCCESS | time=10ms

But, I think that one Webhook is just the one for Jenkins probably. We need the one for Bitbucket to work.

Any thoughts?

Update: it looks like the Jenkins Branch Source Plugin is not giving Sonarqube what it needs to recognize the PR as a PR in Sonarqube. It thinks it’s just a normal branch. When we manually set the sonar pullrequest fields it worked. So, something is missing in the automatic setup of the jenkins source branch plugin not sending what is needed for Sonarqube to recognize it as a PR.

-Dsonar.pullrequest.key=1
\

-Dsonar.pullrequest.branch=feature/testing
\

-Dsonar.pullrequest.base=develop

We figured it out. In my Jenkinsfile I was setting the property:
-Dsonar.branch.name=${env.BRANCH_NAME}

This was causing Sonarqube to think this was a BRANCH and not a PR. I just removed that property from the Jenkinsfile command and now it’s working great.

					withSonarQubeEnv('SonarQube') {
						script {
							sh """
								mvn -f ${config.pomPath} sonar:sonar \
								-Dsonar.links.ci=${JOB_URL} 
							"""
						}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.