# Add another pullrequest provider

**URL:** <https://community.sonarsource.com/t/add-another-pullrequest-provider/23235>\
**Category:** Plugin Development\
**Created:** [April 17, 2020, 8:05pm UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235 "2020-04-17T20:05:28Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkusAmshove](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/markusamshove/32/1693_2.png) [@MarkusAmshove](https://community.sonarsource.com/u/MarkusAmshove)\
**Post date:** [April 17, 2020, 8:05pm UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/1 "2020-04-17T20:05:28Z")

</div>

Hello there,

is there any guidance on what to do to create a plugin to add another Pullrequest provider?

We’re using Gitea and I’d like to have at least some of the experience I can see on the features page for other providers.

Whats important to me:

- Populate the branches dropdown with PR informations
- Create whatever is needed on SonarQube to make the analysis of PRs possible

Is this something that I can do on my own?  
Or is there otherwise an option to do these things with the SonarQube REST-API (e.g. a hook on the Gitea side)? If yes, what scanner parameter would I have to pass to make the analyzer recognize the PR?

Thanks in advance! 🙂

---

<div class="post-metadata">

**Author:** ![dmeneses](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/dmeneses/32/2933_2.png) [@dmeneses](https://community.sonarsource.com/u/dmeneses)\
**Post date:** [April 20, 2020, 3:34am UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/2 "2020-04-20T03:34:44Z")

</div>

Hi,  
SonarQube is not designed to get support of additional providers through plugins. The support of ALMs like GitHub and GitLab is mostly for the decoration of the pull request with SonarQube issues. Other than that, it’s mostly a convenience to avoid additional configuration.  
What CI pipeline do you use? Can’t you trigger the analysis of pull requests when a commit happens?

---

<div class="post-metadata">

**Author:** ![MarkusAmshove](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/markusamshove/32/1693_2.png) [@MarkusAmshove](https://community.sonarsource.com/u/MarkusAmshove)\
**Post date:** [April 20, 2020, 7:22pm UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/3 "2020-04-20T19:22:21Z")

</div>

Hi,

is it enough to set some analysis parameter to get the drop down list populated like in the screenshot?

If so, what would be the parameter I need to set to get

- PullRequest ID
- PullRequest Description
- Link to the PullRequest?

I have all information at hand, just need to pass them correctly then.

 ![grafik](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/b997c2dd82a39b25e3fec7f86cdcbc56a5ea767f.png)

Edit: We’re using Gitea to host our repository and Jenkins as CI/CD-Pipeline

---

<div class="post-metadata">

**Author:** ![justus\_bunsi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/justus_bunsi/32/15977_2.png) [@justus\_bunsi](https://community.sonarsource.com/u/justus_bunsi)\
**Post date:** [April 23, 2020, 12:55pm UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/4 "2020-04-23T12:55:18Z")

</div>

Hi Markus,

we are using that Gitea-Jenkins-SonarQube combination, too. 👍  
Are you trying to scan PullRequests created by Gitea with SonarQube or do you try to decorate them in Gitea like it is possible with GitHub and other providers?

Best regards,  
Steven

---

<div class="post-metadata">

**Author:** ![MarkusAmshove](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/markusamshove/32/1693_2.png) [@MarkusAmshove](https://community.sonarsource.com/u/MarkusAmshove)\
**Post date:** [April 24, 2020, 6:07pm UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/5 "2020-04-24T18:07:27Z")

</div>

We’re currently using the Community edition, where I handwrote the decoration of pull requests (e.g. the commit status as `qualitygate`) as [explained here](https://github.com/go-gitea/gitea/issues/8096#issuecomment-544511510).

We’re looking at trying out the developer edition, but I want to know up front what I can configure so I don’t waste days on configuring it 🙂

Populating the dropdown for PullRequests on the SonarQube project would be a good first step!  
If this opens up easier integration with Gitea\<-\> (e.g. hooks on the SonarQube side to report a commit status) then that would be great too, but not needed 🙂

Can you tell me what parameter you feed to the analyzer?

---

<div class="post-metadata">

**Author:** ![justus\_bunsi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/justus_bunsi/32/15977_2.png) [@justus\_bunsi](https://community.sonarsource.com/u/justus_bunsi)\
**Post date:** [April 28, 2020, 6:40am UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/6 "2020-04-28T06:40:02Z")

</div>

Hi Markus

> [@MarkusAmshove](#):
>
> Populating the dropdown for PullRequests on the SonarQube project would be a good first step!

We are using Enterprise Edition but with at least SonarQube Developer Edition you can analyse PullRequests as described [here](https://docs.sonarqube.org/latest/analysis/pull-request/) from command line or via Jenkins. Do you know the [Gitea plugin for Jenkins](https://github.com/jenkinsci/gitea-plugin)? We are using it and it provides us environment variables containing values you can use for the SonarQube scanner to fill `sonar.pullrequest.base` and `sonar.pullrequest.branch` parameters.  
With these information the scanner can do the “heavy” work for you creating the desired PullRequest analysis in SonarQube.

This Jenkins plugin also automatically decorates your commits in Gitea with its build status (pending, success, failure, general error).

> [@MarkusAmshove](#):
>
> If this opens up easier integration with Gitea\<-\> (e.g. hooks on the SonarQube side to report a commit status)

At the moment we just have such Jenkins build resultd as commit decoration in Gitea. In the context of PullRequests such commit statuses are called `checks` which can be used to prevent PR merges on failures. SonarQube can send webhooks for analysis results to any endpoint. In your referenced GitHub comment it seems that you use such webhooks to report back to Jenkins. I recognized that those webhooks contain more information than Jenkins use and expose to the pipeline.  
It should be possible to build your own decoration or even add comments in Gitea based on SonarQube webhook payload. As the [webhook documentation](https://docs.sonarqube.org/latest/project-administration/webhooks/) describes you can provide additional parameters to the scanner (like commit hash). Those parameters would be included in the resulting webhook post. In that way you should be able to feed Gitea with your desired information using its REST API (and create comments). You described a quite similar way for commit statuses (PR checks) in you GitHub comment.  
For our use case I will evaluate posting a SonarQube webhook and use it as Gitea PR check to prevent merging with existing SonarQube issues.

Best regards,  
Steven

---

<div class="post-metadata">

**Author:** ![MarkusAmshove](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/markusamshove/32/1693_2.png) [@MarkusAmshove](https://community.sonarsource.com/u/MarkusAmshove)\
**Post date:** [May 7, 2020, 7:17am UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/7 "2020-05-07T07:17:59Z")

</div>

Thank you for the suggestions Steven, they’ll be very helpful when we evaluate the developer edition 🙂

In the meantime [Code Reviews via REST API](https://github.com/go-gitea/gitea/pull/11224) were implemented for the next Gitea release, so I hope we can e.g. fork the GitLab extension for SonarQube and implement the same integration for reviews 🙂

---

<div class="post-metadata">

**Author:** ![justus\_bunsi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/justus_bunsi/32/15977_2.png) [@justus\_bunsi](https://community.sonarsource.com/u/justus_bunsi)\
**Post date:** [May 7, 2020, 1:44pm UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/8 "2020-05-07T13:44:21Z")

</div>

I didn’t know about this planned Gitea feature. This is amazing 😃. Please keep me posted about your fork for the GitLab extension.

---

<div class="post-metadata">

**Author:** ![MarkusAmshove](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/markusamshove/32/1693_2.png) [@MarkusAmshove](https://community.sonarsource.com/u/MarkusAmshove)\
**Post date:** [May 27, 2020, 7:03am UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/9 "2020-05-27T07:03:52Z")

</div>

I’m successfully using the Developer Edition trial at the moment with PullRequests from Gitea (via the parameters you mentioned and from the docs) 🙂

Is there a way to also pass the Title of the PR as parameter to the scanner?  
It sadly seems like if we can’t build a custom plugin for Gitea as real scm provider (like Github, GitLab, …) we can’t get the titles of the PRs into the SonarQube UI :-/

---

<div class="post-metadata">

**Author:** ![justus\_bunsi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/justus_bunsi/32/15977_2.png) [@justus\_bunsi](https://community.sonarsource.com/u/justus_bunsi)\
**Post date:** [July 6, 2020, 6:27am UTC](https://community.sonarsource.com/t/add-another-pullrequest-provider/23235/10 "2020-07-06T06:27:31Z")

</div>

Hi. Totally missed your latest response. 😬

> [@MarkusAmshove](#):
>
> Is there a way to also pass the Title of the PR as parameter to the scanner?

As far as I know there is no way to pass a title or description for the PR through cli parameters to the scanner except for `sonar.pullrequest.key`, `sonar.pullrequest.branch` and `sonar.pullrequest.base`. The key must be unique so we cannot use it to pass a highly customizable value like subjects without risking collisions inside of SonarQube.

What would be the benefit of having the title of the PR in SonarQube UI when you already have the PR number as identifier?
