Q: Can I fail the build - or block a deployment - when code coverage drops below a given percentage?
Yes. Set the targetPercentage parameter and call the
clover:check goal (Maven) or the
<clover-check> task (Ant).
<configuration>
<targetPercentage>75%</targetPercentage>
</configuration>
mvn clean clover:setup test clover:aggregate clover:clover clover:check
If you want the build to succeed anyway and only print a warning, use
-DfailOnViolation=false.
See Configuring a coverage goal for Maven and <clover-check> for Ant, including how to ratchet coverage up by failing the build when coverage drops relative to a previous history point.
Blocking a deployment on a CI server
There is usually no separate "coverage gate" setting on a CI server - this is Clover's
configuration, not the CI server's. Because clover:check fails the build when the
threshold is not met, simply make your deployment depend on a successful build.