I've read that we can configure JaCoCo to fail the maven build if the test code coverage is below a predefined threshold but how about if we want to fail the build if the test code coverage drops from the previous test code coverage?
The Code Coverage API Jenkins plugin comes with a REST API which includes:
Coverage result of last build:
…/{buildNumber}/coverage/…/last/result/api/\{json|xml\}?depth={number}
The idea would be to define a step for storing that value in a variable, and then use said variable in limit configuration:
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>${env.LAST_BULD_COVERAGE}</minimum>
</limit>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With