将异常消息传递到Jenkins管道中的Shell脚本

script {
    try {
      echo $currentBuild.currentResult
      //this will fail,hence catch is triggered
    } catch (e) {
        withCredentials([string(credentialsId: 'ZWB',variable: 'zoom_WEBHOOK'),string(credentialsId: 'ZTK',variable: 'zoom_TOKEN')]){
            sh 'bash Scripts/Staging/notification_fail.sh ${currentBuild.currentResult}'
        }
    }
}

您可能会猜到,我在可执行Shell中使用$ 1和$ 2。我想要的是让$ 2接受e.getMessage()的值,以便让我的缩放通知脚本在发送时附上错误消息。

我试图像这样直接附加它:

sh 'bash Scripts/Staging/notification_fail.sh ${currentBuild.currentResult}'+e.getMessage()

基于的语法

echo "ERROR MESSAGE: "+e.getMessage()

该方法有效,因此我尝试对其进行仿真。

因此,我想知道将e.getMessage()的值传递给我的可执行外壳的任何其他方法,以及是否有一种直接访问$ currentBuild.currentResult和e.getMessage的值的方法。 ()在可执行Shell中。

fengseyuer 回答:将异常消息传递到Jenkins管道中的Shell脚本

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3155335.html

大家都在问