詹金斯管道与并行 [英] Jenkins pipeline with parallel

查看:219
本文介绍了詹金斯管道与并行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Here is my Jenkins pipeline that i am trying to execute. I am following 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 job fails with following 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 out why this is failing.

推荐答案

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

You need to add a steps block after your 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"
                        }
                )
            }
        }
    }
}

这篇关于詹金斯管道与并行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆