# Pull Requests Analysis with GitHub

**URL:** <https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885>\
**Category:** SonarQube Server / Community Build\
**Tags:** jenkins, pull-request, sonarqube\
**Created:** [August 7, 2019, 2:36pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885 "2019-08-07T14:36:59Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 7, 2019, 2:36pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/1 "2019-08-07T14:36:59Z")

</div>

Hi,  
We are trialing SonarQube Developer Edition 7.9.1.27448 mainly because of its PR analysis. Unfortunately, I’ve learnt that GitHub is not officially supported by SQ.  
I wanted to give it a try anyway, hoping that the API is still compatible.  
I’ve set everything according to the documentation, however I can’t see any decorations on the PR page.  
The logs [sonarqube.txt](https://community.sonarsource.com/uploads/short-url/wToGMdGhg8csz6OQsfB06gVkktR.txt) (7.7 KB) however show all success statuses - should there be a line here that indicates SQ tried to decorate a PR? Is there any way to debug the issue?  
Also, documentation mentions setting per project Administration \> Pull Requests \> sonar.pullrequest.github.repository  
but I couldn’t find any field like that in 7.9.1.  
Instead, I’m running sonar scanner from jenkins with following arguments:  
`sonar-scanner -Dsonar.pullrequest.key=70 -Dsonar.pullrequest.branch=test -Dsonar.github.repository=mycompany:test-app`

Is there any change that GitHub API will be supported? Otherwise, there is not much reason for us to use Developer edition and will have to downgrade to older version and use GitHub plugin instead

Thanks,  
Jan

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 8, 2019, 12:33pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/2 "2019-08-08T12:33:31Z")

</div>

Hi Jan,

Welcome to the community!

It looks like the UI path in the docs is slightly off. Under the project **Administration** menu, choose **General Settings** , and _then_ **Pull Requests** from the list on the side.

You _must_ specify the properties about _where_ to decorate server-side because PR decoration happens asynchronously on the server-side at the end of analysis report processing. At that point, the properties you passed in on the analysis command line are out of scope.

Regarding SonarQube + [GitHub.com](http://GitHub.com), it works, but if there are major API changes on the GitHub side, we won’t be backporting fixes to the LTS. If you’re willing to keep up with the latest version, then you should be golden (once you get over this initial configuration hump).

&nbsp;  
🙂  
Ann

---

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 8, 2019, 1:25pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/4 "2019-08-08T13:25:38Z")

</div>

Hi Ann,

thanks the for replay. The thing is, that I’ve set properties in Administration \> General Settings \> Pull Requests.  
I’ve set:  
sonar.pullrequest.provider = GitHub  
sonar.pullrequest.github.endpoint = [https://api.github.com](https://api.github.com)  
sonar.alm.github.app.name = name of the app from GitHub Apps page  
sonar.alm.github.app.id = ID of the app from GitHub Apps page  
sonar.alm.github.app.privateKeyContent.secured = content of private key file generated by GitHub (should in include the starting “-----BEGIN RSA PRIVATE KEY-----” part?)

I understand that it’s an asynchronous operation run server-side, that’s why I was hoping to see anything in the logs from SQ server that would at least tell me, that it tried to communicate with GitHub and failed to connect to app/authenticate or anything. Right now I’m not even sure, if SQ tries to connect to GitHub or now.  
Is there any other property that I need to pass to sonar-scanner, when I analyze a PR? For sure the PR are analyzed correctly, I can view a project and get a list of master and all PR, however, a PR that is shown in SQ with 2 code smells never received any decorations on the github page.

Edit: The GitHub App name contains a dash `CompanyName-Sonarqube` - is something like that definitely supported?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 8, 2019, 1:42pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/5 "2019-08-08T13:42:11Z")

</div>

Hi Jan,

Before we dive into PR decoration, are your other questions answered? Is this thread now dedicated to PR decoration?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 8, 2019, 1:46pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/6 "2019-08-08T13:46:19Z")

</div>

Yes, I’m now only concerned about making PR decorations work

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 8, 2019, 1:47pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/7 "2019-08-08T13:47:18Z")

</div>

Hi again,

Nevermind. I’m getting my threads mixed up. 🙄

Have you [installed your app on the GitHub side](https://docs.sonarqube.org/latest/instance-administration/github-application/)?

&nbsp;  
Ann

P.S. I’m dodging the logs question right now because I’m not sure.

---

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 8, 2019, 1:47pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/8 "2019-08-08T13:47:52Z")

</div>

Yes, we did.

---

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 9, 2019, 10:52am UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/10 "2019-08-09T10:52:34Z")

</div>

Hi Ann,

did a bit of progress with the topics. I’ve found this amazing warning icon in the right corner of the PR analysis, that told me, that `sonar.pullrequest.github.repository` was missing (for some reason I was using `sonar.pullrequest.repository` instead…).  
Now I’m getting  
`Pull request decoration did not happen. No commit found for revision '2a73ce5d463d563a7993e40fe9596b79b6229f58'. Please pass a valid commit revision to the scanner using 'sonar.scm.revision' parameter`

But with the warning sign I should be able to resolve any issues.  
Btw, do you know if in case of GitHub `sonar.pullrequest.branch` should be set to the name of original PR branch name or the `PR-XXX` name?

Thanks,  
Jan

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 9, 2019, 12:17pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/11 "2019-08-09T12:17:20Z")

</div>

Hi Jan,

Are you analyzing the PR as checked out, or a local merge with the target branch? If the latter, then that’s the source of

> [@jkosecki](#):
>
> `No commit found for revision...`

Also, according to the docs, `sonar.pullrequest.branch` should be the name of your original PR branch.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 9, 2019, 1:02pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/12 "2019-08-09T13:02:47Z")

</div>

Yes, I realized that jenkins was creating a new commit of a merge. Got it working by using `sonar.scm.revision=refs/pull/$CHANGE_ID/head` instead.

The check appears now on the GitHub page, but the only issue we have is that all images on the check page are missing, probably because our projects are private. Is there any documentation about that?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 9, 2019, 1:07pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/13 "2019-08-09T13:07:54Z")

</div>

Hi Jan,

Glad you got it working. Regarding the icons, you’re looking for this:

[SONAR-12329](https://jira.sonarsource.com/browse/SONAR-12329) - Missing icons in GitHub Enterprise PR decoration

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![jkosecki](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jkosecki/32/5280_2.png) [@jkosecki](https://community.sonarsource.com/u/jkosecki)\
**Post date:** [August 9, 2019, 1:13pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/14 "2019-08-09T13:13:37Z")

</div>

Hi Ann,

yes, we have the property set. Are you saying, that images should work even with private repositories?  
It is possible, that github IP is not whitelisted and hence missing images - I’ll have to talk with our network administrator about that.

Thank you!

EDIT: Just realized that we are using GitHub Authentication Plugin for SQ, so GitHub has probably access to our SQ instance.

EDIT: Nvm, I see that the fix version is 8.0.0. Looking forward to it! Any idea, when it’s available?

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [August 9, 2019, 1:24pm UTC](https://community.sonarsource.com/t/pull-requests-analysis-with-github/12885/15 "2019-08-09T13:24:07Z")

</div>

Hi Jan,

The current release target for 8.0 is the end of Sept.

&nbsp;  
🙂  
Ann
