Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a Jenkins build be failed for coverage going down?

I've seen a number of posts on making a Maven-backed Jenkins build fail for a given project if a coverage threshold isn't met i.e. coverage must be at least 80% or the build fails.

I'm wondering if there is a way to configure Jenkins to fail a build if the coverage is lower than the last build i.e. if the coverage for build N is 20%, and N+1 is 19%, then the build fails. I don't want to put in an explicit threshold, but I want the coverage to stay steady or get higher over time.

like image 607
GaryF Avatar asked Jun 26 '11 18:06

GaryF


People also ask

Why does Jenkins build fail?

In Jenkins, in the pipeline where failure occurred, in the pane, select the latest build, and click Console Output. On the Console Output page, check the logs to find the reason for the failure. If required, update the parameters in the deployment input configuration file.

What happens if build fails in Jenkins?

The Build Failure Analyzer Jenkins plugin analyzes the causes of failed builds and presents the causes on the build page. It does this by using a knowledge base of build failure causes maintained from scratch.

How do you fail a Jenkins build pipeline?

You can use the error step from the pipeline DSL to fail the current build. error("Build failed because of this and that..")

How does Jenkins check test coverage?

If you click on the Coverage Report icon, you will see code coverage for each package in your application, and even drill down to see the code coverage (or lack thereof) for an individual class (see Figure 2.31, “Jenkins lets you display code coverage metrics for packages and classes”).


1 Answers

I haven't tried it, but assuming you are using maven cobertura plugin, I believe it can be configured to fail as documented here. Would jenkins not honour the failure?

I also see an open feature request for this.

like image 143
Raghuram Avatar answered Oct 11 '22 23:10

Raghuram