Home > Software design >  Jenkins Error: "Unknown stage section "stage". Starting with version 0.5, steps in a
Jenkins Error: "Unknown stage section "stage". Starting with version 0.5, steps in a

Time:09-29

Per my header, I'm receiving the following error for my jenkins setup:

Unknown stage section "stage". Starting with version 0.5, steps in a stage must be in a 'steps' block. @line xxx, column xx.
stage('First Parallel Stage') {
^

My configuration:

pipeline {
    stages {
        stage('Header_1'){
            steps{}
        }
        stage('Header_2'){
            steps{}
        }
        parallel{
            stage('First Parallel Stage'){
                environment{}
            }
            stages {
                stage('Another_One'){
                    steps{}
                }
            }
        }
     }
 }

I've tried putting an empty steps{} in stage('First Parallel Stage') and tried putting it inside steps. I'm unsure what could be wrong.

CodePudding user response:

You'll need to put stages that are grouped together into a stage and parallel must be within a stage too. Full working example:

pipeline {
    agent any

    stages {
        stage('Header_1'){
            steps{
                echo '1'
            }
        }
        stage('Header_2'){
            steps{
                echo '2'
            }
        }
        
        stage('Parallel') { // add this
            parallel {
                stage('First Parallel Stage'){
                    environment{
                        TEST = 3
                    }
                    
                    steps {
                        echo "$TEST"
                    }
                }
                
                stage('Execute this together') { // add this
                    stages {
                        stage('Another_One'){
                            steps{
                                echo "4"
                            }
                        }
                        
                        stage('Yet Another_One'){
                            steps{
                                echo "5"
                            }
                        }
                    }
                }
            }
        }
     }
 }

Please note that you can't have parallel{} inside of parallel{}, but you can chain them.

On BlueOcean it then looks like the following:

enter image description here

  • Related