Jenkins pipeline with parallel

Here is my Jenkins pipeline I'm trying to execute. I follow this tutorial :

pipeline {
    agent any
    stages {
        stage('one') {
            parallel "first" : {               
                    echo "hello"                
            },
            "second": {                
                    echo "world"            
            }
        }
        stage('two') {
            parallel "first" : {               
                    echo "hello"                
            },
            "second": {                
                    echo "world"            
            }
        }
    }
}

But the operation fails followed by a message.

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 4: Unknown stage section "parallel". Starting with version 0.5, steps in a stage must be in a steps block. @ line 4, column 9.
           stage('one') {
           ^

WorkflowScript: 12: Unknown stage section "parallel". Starting with version 0.5, steps in a stage must be in a steps block. @ line 12, column 9.
           stage('two') {
           ^

WorkflowScript: 4: Nothing to execute within stage "one" @ line 4, column 9.
           stage('one') {
           ^

WorkflowScript: 12: Nothing to execute within stage "two" @ line 12, column 9.
           stage('two') {
           ^

4 errors

Can someone please help me why this fails.

+6
source share
1 answer

You need to add a block of steps after the stage declaration.

pipeline {
    agent any
    stages {
        stage('one') {
            steps {
                parallel("first": {
                    echo "hello"
                },
                        "second": {
                            echo "world"
                        }
                )
            }
        }
        stage('two') {
            steps {
                parallel("first": {
                    echo "hello"
                },
                        "second": {
                            echo "world"
                        }
                )
            }
        }
    }
}
+15
source

Source: https://habr.com/ru/post/1016298/


All Articles