Jenkins构建会因覆盖率下降而失败吗? [英] Can a Jenkins build be failed for coverage going down?
问题描述
如果没有达到覆盖率阈值(即覆盖率必须至少为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.
推荐答案
在侧面保存最后一个覆盖率.使用可访问
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.
这篇关于Jenkins构建会因覆盖率下降而失败吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!