尝试从子作业中提取信息时,Jenkins 出现“ErrorAction$ErrorId: edf4f356-929c-4720-a57f-b2bdef027f2c”错误

问题描述 投票:0回答:1

我有一个用例,我想从父作业中的子作业中提取信息。

这是我的管道脚本:

pipeline {
  agent any
    stages {
    stage('Validate Other Job') {
        steps {
            script {
                echo "triggerring build"
                   def triggeredJob = build job: 'Pipeline1'
                   def logs = triggeredJob.rawBuild.getLog(100)
                   echo "Logs '$logs'"
                   }
                }
            }
       }
}

输出:当“Pipeline1”作业状态为:SUCCESS 时 它打印日志

问题:当“Pipeline1”作业状态为:FAILURE 或 UNSTABLE 时 它抛出错误:

Build Pipeline1 #18 completed: FAILURE
   [Pipeline] }
   [Pipeline] // script
   [Pipeline] }
   [Pipeline] // stage
   [Pipeline] }
   [Pipeline] // node
   [Pipeline] End of Pipeline
   Pipieline1 #18 completed with status FAILURE (propagate: false to ignore)
  org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: edf4f356-929c-4720- 
  a57f-b2bdef027f2c
  Finished: FAILURE

我的用例是在构建失败/不稳定时获取日志,并检查日志中特定字符串是否可用。如果是,则触发邮件。

童工是一个虚拟的工作:

pipeline {
agent any

stages {
    stage('Hello') {
        steps1 { // step1 for marking the build fail for testing
            echo 'Hello World'
        }
      }
    }
  }
jenkins jenkins-pipeline jenkins-groovy
1个回答
0
投票

默认情况下,下游构建失败会导致上游构建失败,因此您甚至无法进行日志解析。要禁用它,请将

propagate: false
参数传递给
build
[步骤][1]。如果您仔细阅读日志,它会告诉您这一点。

[1]:https://www.jenkins.io/doc/pipeline/steps/pipeline-build-step/#:~:text=password-,propagate%20%3A%20boolean%20(可选),-如果%20启用%20(默认

© www.soinside.com 2019 - 2024. All rights reserved.