Jenkinsfile嵌套阶段抛出错误

时间:2018-07-31 14:34:35

标签: jenkins jenkins-pipeline

我有以下Jenkinsfile,我相信它已正确设置。我以https://jenkins.io/doc/book/pipeline/syntax/#sequential-stages为例,但是由于某种原因,当我在接收的詹金斯中运行它时,

  

WorkflowScript:11:未知的阶段部分“阶段”。从...开始   版本0.5中,阶段中的步骤必须位于步骤块中

有人可以告诉我我在想什么或做错了吗?

pipeline {
    agent {label 'windows'}

    stages {
        stage('Quick Build') {
            steps {
                echo 'Building'
            }
        }
        stage('Deploy to Dev') {
            // when {
            //     branch 'develop' 
            // }
            stages {
                stage('Building Distributable Package') {
                    steps {
                        echo 'Building'
                    }
                }
                stage('Archiving Package') {
                    steps {
                        echo 'Archiving Aritfacts'
                        archiveArtifacts artifacts: '/*.zip', fingerprint: true
                    }
                }
                stage('Deploying Dev') {
                    steps {
                        echo 'Deploying'
                        timeout(time:3, unit:'DAYS') {
                            input message: "Approve build?"
                        }
                    }
                }
            }

        }
        stage('Deploy to Test') {
            when {
                branch 'develop' 
            }
            steps {
                echo 'deploying..'
                timeout(time:3, unit:'DAYS') {
                    input message: "Approve build?"
                }
            }
        }
        stage('Deploy to Prod') {
            when {
                branch 'release' 
            }
            steps {
                timeout(time:3, unit:'DAYS') {
                    input message: "Deploy to Prod?"
                }
                echo 'Deploying....'
            }
        }
    }
}

谢谢!

1 个答案:

答案 0 :(得分:2)

这最终成为版本2.107.3。中的问题。升级到2.121.2后,此功能便开始起作用。