一尘不染

詹金斯管道与并行

jenkins

这是我要执行的Jenkins管道。我正在关注本教程

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

但是作业失败,并显示以下消息。

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

有人可以帮我解决为什么失败了。


阅读 236

收藏
2020-07-25

共1个答案

一尘不染

您需要在阶段声明之后添加一个step块。

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