【问题标题】:Jenkinsfile nested stage(s) throwing errorJenkinsfile 嵌套阶段抛出错误
【发布时间】:2019-01-08 00:00:25
【问题描述】:

我有以下 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....'
            }
        }
    }
}

提前致谢!

【问题讨论】:

  • 您的脚本看起来不错。我还通过在 Jenkins v2.121.1 中运行来验证它
  • 我在 2.107.3,我会升级看看是否能解决我的错误。
  • 尝试了when 语法之一,它对我有用stackoverflow.com/questions/37690920/…

标签: jenkins jenkins-pipeline


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-05-29
    • 1970-01-01
    • 1970-01-01
    • 2019-05-20
    • 1970-01-01
    • 2018-07-15
    • 1970-01-01
    • 1970-01-01
    • 2018-03-31
    相关资源
    最近更新 更多