Unable to decorate pull request on github

Hi Guys,

I am trying to decorate pull requests with SonarQube 7.7 Developer Edition but I am unable to do so.
The current system works like this
Pull Request -> Jenkins(hosted on GCP) -> SonarQube(Hosted on GCP) -> Github

Sonar is successfully scanning and generating a report via Jenkins but it is not decorating the github pull request.

I am trying to achieve this

Any and all help is greatly appreciated.

Hey Juliana,

PR Decoration has changed quite a bit since January 2017, when that article was published. I would reccomend checking out the current docs on GitHub Enterprise Integration (for some reasons, primarily Beta APIs, we can’t explicitly say we support Github.com / SonarQube, but it should work, see Pull Request Analysis: Decorate PRs in GitHub for @ganncamp’s in depth footnotes :slight_smile: ).


1 Like

Hi Colin,

Thanks for the update.
Currently our organisation does not have github enterprise and are trying to get pull requests to work with github.com.
We were planning to move to Sonar+Jenkins from CircleCI which we currently use and PR decoration is an important feature that was essential to our developers.
There is a PoC the coming Tuesday regarding whether we would like to move onto Sonar officially.
Not having pull request decoration is going to be a major shortcoming and will result in the transfer to Sonar being either rejected or postponed.
Is there a way to get PR decoration for github.com?

Double check my last post (which I edited, perhaps you did not see the changes). It should work with Github.com, but we can’t declare official support.

Did check the same, in jenkins I am setting the following parameters 30%20PM

Also sonar console shows pr decoration failed as in the screenshot.

(Kindly note I am testing it for a test repository, an app would fix the problem?)
What am I doing wrong?

Let’s focus on small chunks of the process, first the GitHub App Setup

Did you follow the instructions regarding setting up a Github App on your organization?

Yep done.
Still getting the warnings message and no decoration.

Nevermind problem solved.
Thanks Colin :slight_smile:

Hi Colin,

I am getting another error when it’s displaying the checks

If you notice the Urls that are being displayed there, they are all my internal ip address
10.x.x.x so the links are broken,
Why isn’t it pointing to the sonar url(external ip address where sonar check ran)?

Make sure you have sonar.core.serverBaseURL set correctly in your global Administration > General settings.

Thanks :slight_smile: Links are fixed. But images are still broken.

Probably this bug:

Which should be fixed when our 7.x LTS drops next month (fingers crossed) :slight_smile: I think it’s a side effect of the GitHub.com / SonarQube on-prem combo, but to be honest I’m not 100% sure


1 Like

Well I certainly hope too.
If I am not wrong PR decoration is part of the Community Edition but branch analysis is part of the Developer Edition right? or its just the latter that supports it

PR decoration and branch analysis are both in the Developer Edition.


Nevermind fixed.

Thanks @simon.brandhof @ColinHMueller

I am getting this warning
Could not find ref ‘{ghprbTargetBranch}’ in refs/heads or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.

Could not find ref ‘master’ in refs/heads or refs/remotes/origin. You may see unexpected issues and changes. Please make sure to fetch this ref before pull request analysis.

This happens only when there’s a pull request to master
Any idea how to overcome it?


It’s getting rather hard to follow this thread when you edit your posts to remove the issues you faced – the solutions you find for yourself may help other users and it would be a good practice to post them (part of the unwritten contract of being in a community like this :slight_smile: )

It looks like {ghprbTargetBranch} is not being resolved correctly in Jenkins. I’m assuming you’re using this GitHub plugin, I’d double check that you have the variable defined correctly (it looks like it needs to be prefixed with $).


I’m sorry my bad. Most of them were becuase I didn’t save the settings or the server was down, the shared compute engine we use for testing PoCs was being overloaded.(Yes it’s an unwritten social contract :slight_smile:)
Yes correct I am using that github plugin.
Yup it’s working thanks!

@ColinHMueller I am facing another issue.

It so happens that pull requests are being built appropriately and I am able to run a code analysis.
Unfortunately on a merge event sonar is not scanning the master branch and providing an analysis report. So sonar is still showing the build report for the first time master was scanned.

Notice the box on the right.
How do I go about fixing this?

I was able to fix it by selecting the following in Jenkins

  1. GitHub hook trigger for GITScm polling
  2. Poll SCM

@ColinHMueller @simon.brandhof I am having another issue.
When I run sonar analysis on master branch (whenever there is a merge to master), sonar shows 0 problems.

Ideally we want master to run as a fresh analysis on merge, to show all issues till date as we can monitor our progress on the master branch.

How do I go about solving this issue?

According to you screenshot the properties sonar.pullrequest.* are always declared, even when analysing master. That should not be the case. They should be unset when analysing a branch that is not associated with a pull request.

1 Like