# Sonarqube 8.2 automatic/programmatic Github Pull Request decoration?

**URL:** <https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934>\
**Category:** SonarQube Server / Community Build\
**Created:** [April 11, 2020, 9:34pm UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934 "2020-04-11T21:34:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_Zin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nicolas_zin/32/10854_2.png) [@Nicolas\_Zin](https://community.sonarsource.com/u/Nicolas_Zin)\
**Post date:** [April 11, 2020, 9:34pm UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934/1 "2020-04-11T21:34:45Z")

</div>

Hi,

I have a similar question than [Is there's any way to auto configure the sonarqube pull request decoration](https://community.sonarsource.com/t/is-theres-any-way-to-auto-configure-the-sonarqube-pull-request-decoration/22154) but for Github:

- I just upgraded to Sonarqube 8.2
- our sources (and our PRs) are on Github
- we have \> 400 projects scanned by SonarQube
- before (i.e Sonarqube 7.9.x) we could have Pull Request decoration automatically, but after the migration it seems that it is no longer the case. Apparently if I want them back, I need to go over each project to manually add PullRequest decoration and select the GitHub repository

I have 2 questions:

- can I automatically/programmatically set the PR decoration on all existing project (without going through \> 400 UI pages)
- can I programmatically set PR decoration when I add new project to scan

Regards

---

<div class="post-metadata">

**Author:** ![abhishektaneja](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/abhishektaneja/32/10452_2.png) [@abhishektaneja](https://community.sonarsource.com/u/abhishektaneja)\
**Post date:** [April 11, 2020, 10:39pm UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934/2 "2020-04-11T22:39:50Z")

</div>

hey ,  
you can use the sonarqube API for this,

> curl -X “POST” “http://\*\*\*\*/api/alm\_settings/set\_bitbucket\_binding”   
> -H ‘Content-Type: application/x-www-form-urlencoded; charset=utf-8’   
> -u ‘\*\*\*:\*\*\*’   
> –data-urlencode “almSetting=\*\*\*”   
> –data-urlencode “project=\*\*\*”   
> –data-urlencode “repository=\*\*\*”   
> –data-urlencode “slug=\*\*\*”

---

<div class="post-metadata">

**Author:** ![aurelie](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/aurelie/32/849_2.png) [@aurelie](https://community.sonarsource.com/u/aurelie)\
**Post date:** [April 14, 2020, 2:50pm UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934/4 "2020-04-14T14:50:58Z")

</div>

Hi @Nicolas_Zin,

Welcome to our community forum and thanks @abhishektaneja for helping 🙂

I’ll try to give additional information here :

> [@Nicolas\_Zin](#):
>
> can I automatically/programmatically set the PR decoration on all existing project (without going through \> 400 UI pages)

Normally, it should be the case automatically for existing projects with PR decoration, after you perform a PR analysis after the migration, the properties should be set automatically

- Could you please check and let us know, otherwise we will investigate what’s not working.
- Are you using the Developer Edition? If you are using another Edition, it may also explain some errors.

> [@Nicolas\_Zin](#):
>
> can I programmatically set PR decoration when I add new project to scan

It depends on how you create your new projects on SQ:

- if you create them on the UI, you have to set up the properties manually on the project settings after the project creation. Note that we want to improve this part and set automatically the properties by selecting the repository at project creation.
- if you create them via a script, you can use the API.

Also to help us in our improvements, I would be happy to know how you create your projects in SQ, and especially, do you create one project at a time, or several projects at a time?

Thanks

---

<div class="post-metadata">

**Author:** ![Nicolas\_Zin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nicolas_zin/32/10854_2.png) [@Nicolas\_Zin](https://community.sonarsource.com/u/Nicolas_Zin)\
**Post date:** [April 14, 2020, 3:07pm UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934/5 "2020-04-14T15:07:40Z")

</div>

Thanks for the pointer @abhishektaneja.  
I manage to have something working (for Jenkins):

```auto
           withCredentials([string(credentialsId: 'admin-sonar-token', variable: 'SONARQUBE_ADMIN_TOKEN')]) {
               sh """\
               curl
               --verbose
               --user ${env.SONARQUBE_ADMIN_TOKEN}:
               --data "almSetting=myalmsettingName"
               --data "project=${properties['sonar.projectKey']}"
               --data "repository=${gitRepo}"
               --request POST
               ${properties['sonar.host.url']}/api/alm_settings/set_github_binding
               """.stripIndent().readLines().join(' ')
           }

```

---

<div class="post-metadata">

**Author:** ![Pragathi\_Punnam](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pragathi_punnam/32/13444_2.png) [@Pragathi\_Punnam](https://community.sonarsource.com/u/Pragathi_Punnam)\
**Post date:** [July 15, 2020, 1:15pm UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934/6 "2020-07-15T13:15:59Z")

</div>

Where can i find these almSetting,project parameters… ???

---

<div class="post-metadata">

**Author:** ![pkazi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pkazi/32/19013_2.png) [@pkazi](https://community.sonarsource.com/u/pkazi)\
**Post date:** [June 24, 2021, 6:14am UTC](https://community.sonarsource.com/t/sonarqube-8-2-automatic-programmatic-github-pull-request-decoration/22934/7 "2021-06-24T06:14:48Z")

</div>

@Pragathi_Punnam You can get it from Web API age of your SQ instance. (Its preferred, as API docs will be as per your SQ version)  
Else you can always get latest API docs from -  
[https://next.sonarqube.com/sonarqube/web\_api/api/alm\_settings/set\_bitbucket\_binding](https://next.sonarqube.com/sonarqube/web_api/api/alm_settings/set_bitbucket_binding)
