首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >即使并行阶段失败,也继续连续的阶段

即使并行阶段失败,也继续连续的阶段
EN

Stack Overflow用户
提问于 2021-06-16 11:32:28
回答 1查看 274关注 0票数 0

我有这样的管道

代码语言:javascript
复制
pipeline {
agent any
options {parallelsAlwaysFailFast()}
stages {
    stage('Non-Parallel Stage') {
        steps {
            echo 'This stage will be executed first.'
        }
    }
    stage('Parallel Stage') {
        parallel {
            stage('Branch A') {
                agent {
                    label "trfw"
                }
                steps {
                    sh 'exit -1'  // fails here
                    echo "On Branch A"
                }
            }
            stage('Branch B') {
                agent {
                    label "trfw"
                }
                steps {
                    echo "On Branch B"
                }
            }
            stage('Branch C') {
                agent {
                    label "trfw"
                }
                stages {
                    stage('Nested 1') {
                        steps {
                            echo "In stage Nested 1 within Branch C"
                        }
                    }
                    stage('Nested 2') {
                        steps {
                            echo "In stage Nested 2 within Branch C"
                        }
                    }
                }
            }
        }
    }
    stage('validator Stage') {
        steps {
            echo 'This validator stage should run even after falure of other stages.'
        }
    }
  }
}

在上面的管道中,当并行阶段失败时,所有其他阶段都会失败(同时也是顺序的),因为我在选项中使用了"parallelsAlwaysFailFast()“。我只想在失败的情况下并行地失败,而不是顺序的(验证器)。我有办法做到这一点吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-18 07:29:50

实现的一种方法是使用post生成操作。

代码语言:javascript
复制
pipeline {
agent any
options {parallelsAlwaysFailFast()}
stages {
    stage('Non-Parallel Stage') {
        steps {
            echo 'This stage will be executed first.'
        }
    }
    stage('Parallel Stage') {
        parallel {
            stage('Branch A') {
                agent {
                    label "trfw"
                }
                steps {
                    sh 'exit -1'  // fails here
                    echo "On Branch A"
                }
            }
            stage('Branch B') {
                agent {
                    label "trfw"
                }
                steps {
                    echo "On Branch B"
                }
            }
            stage('Branch C') {
                agent {
                    label "trfw"
                }
                stages {
                    stage('Nested 1') {
                        steps {
                            echo "In stage Nested 1 within Branch C"
                        }
                    }
                    stage('Nested 2') {
                        steps {
                            echo "In stage Nested 2 within Branch C"
                        }
                    }
                }
            }
        }
    }
  }
  post {
            always{
                    echo 'This should run even after failure of other stages.'
                }
        }

} 

Jenkins输出

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68001871

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档