Quality Gate not breaking on low coverage score


(vincent) #1

I can’t seem to get our quality gates to fail if the code coverage is below the threshold.

Currently Sonar is set to 80% but I have instances where it’s < 80% and it still passes.

I even created my own quality gate with a 95% threshold and unfortunately that one also pass builds with lower coverage.

How can I get the coverage threshold to make a difference ?


(Wouter Admiraal) #2

Hi @vinny, welcome to the community!

In the Sonar Way quality gate, the coverage that matters is the coverage on new code. This means that, even if your project has less than the desired coverage, the build will still pass. The idea is to focus on the quality of new code. Could that be the answer?

If you navigate to your organization page, and then to Quality Gates, you can see what condition you have on coverage. Try changing it from “on New Code” to the regular one, and trigger a new analysis. That should make the quality gate fail.

However, we do encourage people to focus on their new code. If you haven’t already, I highly encourage you to have a look at our documentation: Fixing the Water Leak

Let me know how it goes.