Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SonarQube doesn't comment on GitHub pull requests

I'm trying to set up SonarQube to comment on my GitHub pull requests after a successful Travis build.

I've already have normal analysis working. For the pull request analysis I also have all tokens in place, plugins installed, etc. Issues in the pull request are successfully identified: the debug log shows successful HTTP requests where the server responds with the relevant issues. Some lines of the log:

15:06:10.194 INFO: ANALYSIS SUCCESSFUL
15:06:10.197 DEBUG: Post-jobs : GitHub Pull Request Issue Publisher (wrapped)
15:06:10.197 INFO: Executing post-job GitHub Pull Request Issue Publisher (wrapped)

On GitHub I can see that the oauth token used by sonar is actually being used.

When adding commits to a pull request, there even is a status for sonarqube: when a new commit is added, for a short while it is waiting for a response, then it changes to "SonarQube reported no issues". Note that this status appears before the sonar scanner has ran on Travis.

Does anyone know what could be the problem or what I could do to debug this any further? Thanks in advance!

like image 407
vandenheuvel Avatar asked Mar 12 '17 15:03

vandenheuvel


People also ask

How do I run SonarQube on a Pull Request?

Pull Requests (PRs) are visible in SonarQube from the branches and pull requests dropdown menu of your project. PR analysis allows you to: see your PR's Quality Gate status in the SonarQube UI. automatically decorate your PRs with SonarQube issues in your SCM provider's interface.

How do I enable Pull Request decorations in SonarQube?

If you're creating a new project Manually or want to add Pull Request decoration to an existing project, set your project settings at Project Settings > General Settings > Pull Request Decoration.

What is Sonar Pull Request key?

sonar.pullrequest.key. Unique identifier of your Pull Request. Must correspond to the key of the Pull Request in your DevOps Platform. e.g.: sonar.pullrequest.key=5.


1 Answers

in case it helps, I was having the same issue. This issue report helped me.

To summarize, this problem can be due to one or more of the following factors:

  1. Sonarqube's analysis mode needs to be set to preview (-Dsonar.analysis.mode=preview) otherwise it seems it won't attempt to connect to GitHub; it will store the results in the SonarQube database.

  2. If the issues found in your code as a result of the scan have already been saved to the SonarQube's database, it won't send them to GitHub, in other words, there need to be new issues when you run it in preview mode for them to be sent to GitHub.

  3. An obvious one, but always good to double check, make sure your oauth credentails are correct and the parameters named correctly.

  4. Double check the properties "Plugins accepted for Preview mode" and "Plugins excluded for Preview mode" in SonarQube Admin settings (General section) to ensure the Github plugin hasn't been excluded.

There might be more, but hopefully this will help. The ones that were getting me were number 1 and 2.

like image 187
Jose B Avatar answered Oct 28 '22 01:10

Jose B