Jenkins声明式管道添加groovy postbuild脚本

时间:2018-08-28 20:27:49

标签: jenkins jenkins-plugins jenkins-pipeline jenkins-groovy jenkins-declarative-pipeline

我的groovy postbuild脚本

def error = manager.getLogMatcher(".*(Error:(.*)))
if(error?.matches()) {
    manager. addShortText(matcher.group(1))
}

现在我正尝试将其转换为声明性管道语法

pipeline{
    post{
       failure{}
    }
}

因此,在“失败”选项卡中可以添加常规脚本吗?还是我必须添加舞台?我看到有jenkins-badge-plugin,但不确定如何添加正则表达式来查找文本,然后添加批处理

1 个答案:

答案 0 :(得分:1)

您只需要在故障内添加脚本块,如下所示,就可以在其中放置构建后的groovy脚本:

pipeline{
    post{
       failure{
           script{
             //Add your post build script code in case of failure
           }
       }
    }
}
相关问题