Fail Quality Gate if coverage decreases from last analysis

SonarQube version: 7.9.1 LTS
sonar.leak.period = previous_version

We want our Quality Gate to fail if coverage decreases during the leak period, regardless of whether it is still above our threshold of 70% (Example: If coverage from last analysis was 75%, quality gate should fail if coverage on next analysis is 74.9% or lower).

In older versions of SonarQube this could be accomplished by using the condition “Coverage, Delta since last analysis, less than, 0”.

Is there a way to do that with the “Coverage on New Code” condition, like setting it to be less than the coverage value from the previous analysis?


This isn’t available, and as you’ve described it I’m not sure it would be productive. I understand your desire to not let people coast on previous excellent efforts, but as I understand it, if my colleague makes the first commit in the New Code Period and his change is 21 lines (to get past the minimum line count required to apply coverage criteria) and he’s in the unusual position of being able to provide 100% coverage with a reasonable effort. Well… the rest of the team is screwed. We have to have 100% on everything. Or… we start gaming the system.

Instead, I’d consider gradually raising the bar on Coverage on New Code maybe from version to version or month to month.