【问题标题】:Jenkins declarative pipeline add groovy postbuild scriptJenkins 声明式管道添加 groovy postbuild 脚本
【发布时间】:2018-08-28 20:27:48
【问题描述】:

我有 groovy postbuild 脚本

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

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

pipeline{
    post{
       failure{}
    }
}

所以我可以在失败选项卡中添加 groovy 脚本吗?或者我必须添加阶段?我看到有 jenkins-badge-plugin 但不确定如何添加正则表达式来查找文本然后添加批处理

【问题讨论】:

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


    【解决方案1】:

    您只需要在失败中添加脚本块,如下所示,您可以在其中放置您的后期构建 groovy 脚本:

    pipeline{
        post{
           failure{
               script{
                 //Add your post build script code in case of failure
               }
           }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-10
      • 2018-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多