How should I configure branch sonar analysis with a single result for each time?

Hello everyone.

I need help with code analysis from a branch. I need Sonar to check the local code of a branch whenever a new code commit is requested.

The analysis part of each commit is resolved, my problem/challenge is to ensure that the errors highlighted in the first attempt continue to be reported in subsequent commit attemps.

Currently, if the first analysis return an error and a new analysis is performed, Sonar will return “Success”.

So… How do I make the Sonar analysis always return an error until the issue is resolved? Preventing the commit from being carried out.

I’m using Gradle with the “org.sonarqube” plugin in version “” and executing the statement “gradle sonar -Dsonar.inclusions=‘${sources}’‘${branch}’ -Dsonar.newCode.referenceBranch=‘develop’” to capture Sonar analysis feedback. I’m also using the following properties in build.gradle

  • property “”, true
  • property “sonar.qualitygate.wait”, true

SonarQube is at version 10.1.



Welcome to the community!

To be clear, SonarQube 10.1 isn’t supported. Only the LTS, currently 9.9.3, and the latest version, currently 10.3 (10.4 imminent) are supported.

That’s probably unrelated to your current question, but you should nonetheless upgrade at your earliest convenience.

Also a bit tangentially:

There’s no need for that sonar.inclusions argument. I suggest you drop it, just to keep things tidy.

Now, on to your question…

Could you be more explicit about this? Highlighted where? Is this a question of PR decoration or are you truly doing a branch analysis and you’re “losing” issues from the branch’s New Code period?