如果作业失败了三次或更多次,我想禁用它。我发现this solution立即禁用它。但我想等三次。
答案 0 :(得分:5)
您可以从build.previousBuild
获取之前的结果。例如:
def failingForAtLeast(build, n) {
def failed = build.result.isWorseThan(hudson.model.Result.SUCCESS );
if( n <= 1 ) {
return failed;
} else if ( failed && build.previousBuild != null) {
return failingForAtLeast(build.previousBuild, n-1);
} else {
return false;
}
}
if ( failingForAtLeast(manager.build, 3) ) {
manager.build.project.disabled = true
}