6
votes

I have the following Jenkinsfile which I believe is setup correctly. I used https://jenkins.io/doc/book/pipeline/syntax/#sequential-stages as an example but for some reason when I run this in jenkins I am receiving,

WorkflowScript: 11: Unknown stage section "stages". Starting with version 0.5, steps in a stage must be in a steps block

Can someone tell me what I am missing or doing wrong?

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....'
            }
        }
    }
}

Thanks in advance!

1
Your script looks fine. I've also verified it by running in Jenkins v2.121.1Talha Junaid
I am on 2.107.3, I will upgrade and see if that fixes my errors.Grady D
tried one of the when sytax and it worked for me stackoverflow.com/questions/37690920/…TheViralGriffin

1 Answers

9
votes

This ended up being a problem in version 2.107.3. Once upgraded to 2.121.2 this functionality started working.