如何从故障块中从詹金斯管道中的其他STAGE调用STAGE

时间:2019-03-28 21:29:59

标签: jenkins groovy

下面的代码在从故障块调用特定阶段时给我一个错误。感谢有人在这里提供帮助。谢谢!

def remainingStages = true
pipeline {
    agent any

    stages {
        stage('Headless Run') {
            steps{
                echo 'Running stage1..'
                withCredentials([string(credentialsId: 'SauceLabHeadlessAcc', variable: 'BUILD_AUTH')])
            }
            post {
                    success {
                        echo 'Stage 1 completed successfully'
                        script {
                            remainingStages = false
                            echo "Going to next Stage:"+ remainingStages
                        }
                    }

                    failure {
                        echo 'Headless FAILED.. Jumping to Regular '
                        Stage: 'REGULAR run'
                    }
                }
        }

        stage('REGULAR run') {
            when {
                expression {
                    remainingStages
                }
            }
                steps{
                    echo 'Running stage2..'
                }
        }    
    }
}

0 个答案:

没有答案