Jenkins构建会因覆盖率下降而失败吗?

Jenkins构建会因覆盖率下降而失败吗?

问题描述:

如果没有达到覆盖率阈值(即覆盖率必须至少为80%或构建失败),我已经看到了许多使给定项目的Maven支持的Jenkins构建失败的帖子.

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.

我想知道是否有一种方法可以配置Jenkins使构建失败,如果覆盖率低于上一个构建,即如果构建N的覆盖率是20%,而N + 1的覆盖率是19%,那么构建失败.我不想设定一个明确的阈值,但是我希望覆盖范围能够保持稳定或随着时间的推移而提高.

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.

在侧面保存最后一个覆盖率.使用可访问 Groovy插件运行) ="http://javadoc.jenkins-ci.org/" rel ="noreferrer"> Jenkins Java API ,以将当前覆盖率与先前的覆盖率进行比较,如果构建失败,则构建失败.如果您认真决定采用这种方式,我可以提供更多详细信息和代码示例.

Save last coverage percentage on the side. Use Groovy script (run via Groovy Plugin) that taps into Jenkins Java API to compare current coverage level with previous one and fail the build if it drops. If you seriously decide to go this way I can provide more details and code samples.