这是我要执行的Jenkins管道。我正在关注this tutorial

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


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

最佳答案

您需要在阶段声明之后添加一个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"
                        }
                )
            }
        }
    }
}

关于jenkins - Jenkins 管道与并行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43211530/

10-11 22:21
查看更多