Sonarqube quality gate metrics don't work properly on PR

Hey. I’ve integrated Sonarqube with Jenkins, Bitbucket to analyse PR and it worked. Now I’m trying to add a new metrics (critical issue, blocker issue) to the quality gate.

  • Sonarqube DE - Version 8.5.
  • Sonarqube pr analysis don’t recognize new metrics in a code, only code smells. So we can’t prevent developers to merge PR if they break some critical rules.


Welcome to the community!

PR analysis only applies that subset of Quality Gate conditions that relate to New Code (since there’s no “overall” code in a PR, only new code). So if your added conditions aren’t on New Code it’s expected that they won’t kick in here.


Thanks for the response.
Thing that I added conditions to the New Code (critical issues, blocker issues). Then I’m introducing a bugs to the PR (for example: while(true)). Sonarqube can’t recognize it.


How about some screenshots?

  • your QG
  • a PR that’s missing some failing conditions
  • evidence that it should have failed


hey, sure:

  1. first I’ve added a new metrics to the guality gate:

  2. then intentionally introduced some issues

probably you have also noticed that merge button is enabled, even though I’ve introduced some bugs:


Thanks for the screenshots. Your 2nd one is of a branch, rather than a PR (a PR wouldn’t have an “Overall” tab). I suppose that if you went to the SonarQube homepage of the PR you show in your 3rd screenshot, it would show a failing Quality Gate, and this is really a question of PR decoration in BitBucket and of blocking the merge…?

If so, have you checked the docs?