Configure the sonarqube pull request decoration on new project creation


I am attempting to auto setup PR decoration with bitbucket server using SonarQube Dev Ed 8.6.1.

Currently using maven to pass arguments, for example:


The above does not work. I have to manually setup the PR decoration for a project in SonarQube.

I suspect it’s not setting the configuration name, as it’s a required field. How do you set the configuration name (either through an API or with maven parameters)? Or possibly pass/set the alm_setting_uuid (which shouldn’t change unless the link is deleted/recreated).

Hello @Chad,

First of all we won’t be able to troubleshoot much because 8.6.x is neither the LTS (8.9.x) nor the latest (which is still 8.9.x for a few days, soon 9.0 that will released in a couple of days).
You’ll need to upgrade to 8.9.x for us to help you further.

Nevertheless, I can give you a few hints: The properties sonar.pullrequest.bitbucketserver.* that you refer to in your post are old (no longer used) properties.
To analyze a PR with bitbucket you should:

  • Either use the SonarQube project onboarding wizard (Accessible from the [+] icon top right in slightly older SonarQUbe versions, now a full blown “Add project” button top right in SonarQube 8.9)
  • Or you:
    – Configure your bitbucket server integration from the Administration → ALM Integration screen
    – Manually create the project and set the bitbucket project Key and SLUG in the project configuration pages (Project → Settings → General Setting → Pull Request decoration)

Then you can run your pipeline and pass the -Dsonar.pullrequest.key and -Dsonar.pullrequest.branch properties. You should be able to retrieve the values dynamically from some ${bamboo.*} variable.

Hope this helps

Thanks @OlivierK , I’ll work on upgrading to the latest LTS.

Currently we are planning on aprox. 170 micro-services, each with it’s own bitbucket repository. The sonarqube projects are being created automatically by bamboo on the first sonar analysis. Is there a way to update the settings through API or other means? If not I may need to look at inserting an entry into the project_alm_settings table directly if possible, or possibly using curl against the gui.

Hello @Chad,

Yes, by principle everything can be done with the API.
The bitbucket server configuration is something you’d do once for all for all 170 projects so that I’l recommend to provision manually (you may also use api/alm_settings/create_bitbucket APIs if you really want).

Then to create projects and provision Bitbucket project key and SLUG you can use the API api/alm_settings/set_bitbucket_binding to automate the PR decoration settings provisioning