I need to create a sonarqube quality gate condition that fails a build if the code coverage drops from the last version. The leak period is now set as the 'previous_version'. I know that there was a delta analysis feature in the older versions of sonarqube. But I think this is no longer available.

For example, in the previous build the coverage was 30% and in the current build it is 29%. So there is a drop in the overall coverage. In this case I need to fail the build. Again I cannot do absolute comparison(like Coverage < 30 etc.) because the coverage varies in different projects and I am doing a global configuration.

I am using sonarqube 6.7 LTS Community version

Is this even possible? If not is there a different way?

1

There are 1 answers

0
Sunil Kpmbl On

I guess I found a way around this. I setup a rule like this in the quality gate: enter image description here

and added more code to the project without tests.

Then I ran the analysis and my quality gate failed with following message:

enter image description here

(Ignore the coverage on new code rule on the left)

I think the key here was to set the "Over leak period" checkbox ticked