首页 > 解决方案 > 即使另一个管道在詹金斯中失败,我如何才能执行一个管道

问题描述

我有以下(部分)管道

stages {
    stage('bootstrap') {
        parallel {
            stage("Linux") {
                agent { label 'linux' }
                steps {
                    sh 'bootstrap.sh'
                }   
            }   
            stage("Windows") {
                agent { label 'Windows' }
                steps {
                    bat 'bootstrap.bat'
                }   
            }   
        }   
    }   

    stage('devenv') {
        parallel {
            stage('Linux') {
                agent { label 'linux' }
                steps {
                    sh 'devenv.sh'
                }   
            }   
            stage('Windows') {
                agent { label 'Windows' }
                steps {
                    bat 'devenv.bat'
                }   
            }   
        }   
    }     
}   
post {
    always {
        echo "Done"
    }   
}   

问题是当 bootstrap.bat 在 windows 上失败时,devenv 步骤现在被认为是失败的,linux devenv 将不会继续。即使 Windows 早期失败,我也希望获得 linux 管道的结果。

一种选择是将阶段分开,以便 linux 完整管道位于并行执行的一个分支上,而 windows 位于另一个分支上,但也许有一个我不知道的技巧,因为我试过了,但似乎没有是可接受的语法。

编辑

建议的修复不起作用。这是管道

pipeline {
    agent none
    parallel {
        stage('Linux') {
            agent { label 'linux' }
            stages {
                stage('bootstrap') {
                    sh "ls"
                }
                stage('devenv') {
                    sh "ls"
                }
            }
        }
        stage('windows') {
            agent { label 'Windows' }
            stages {
                stage('bootstrap') {
                    bat 'dir'
                }
                stage('devenv') {
                    bat 'dir'
                }
            }
        }
    }

}

这是错误信息

WorkflowScript: 8: Undefined section "parallel" @ line 8, column 5.
       parallel {
       ^

WorkflowScript: 1: Missing required section "stages" @ line 1, column 1.
   pipeline {
   ^

标签: jenkinsjenkins-pipeline

解决方案


推荐阅读