【问题标题】:Jenkins declarative pipeline post always condition throws error in logsJenkins 声明性管道发布总是条件在日志中引发错误
【发布时间】:2020-03-10 11:26:41
【问题描述】:

我正在使用带有发布条件的声明性管道,它会按预期发送电子邮件。但是,如果任何阶段发生故障,它不会在日志中显示实际错误,而是给出以下错误。我每次收到的电子邮件都没有问题。知道如何捕捉实际错误吗?

[流水线] 流水线结束还有:
groovy.lang.MissingPropertyException:没有这样的属性:类错误: groovy.lang.Binding 在 groovy.lang.Binding.getVariable(Binding.java:63)

这是我的发帖条件

post {
       always {emailext (
              body: """
              <html>
              </html>
              """,
              subject: "jenkins-CICD build ${env.JOB_BASE_NAME} #${env.BUILD_NUMBER} is ${currentBuild.result}", 
              mimeType: 'text/html', 
              to: '1111@blahblah.com')}
            }

【问题讨论】:

    标签: jenkins-pipeline


    【解决方案1】:

    一个简单的 try-catch 应该可以工作。

    post { 
         always {
            try {
                 emailext (...)
            } catch (error) { 
              // ignore error
            }
         }
    }
    

    【讨论】:

    • 谢谢迈克尔,我在舞台上使用了 catch(all),但是当我改为 catch (error) 时,它开始给我错误日志。我也会在后期条件下保持同样的状态。真的很有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-02
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    相关资源
    最近更新 更多