如何在詹金斯的单个管道作业中触发多次运行? [英] How to trigger a multiple run in a single pipeline job of jenkins?

查看:147
本文介绍了如何在詹金斯的单个管道作业中触发多次运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个管道作业,该管道作业使用以下管道常规脚本运行,

I have a pipeline job which run with below pipeline groovy script,

pipeline {
     parameters{
    string(name: 'Unique_Number', defaultValue: '', description: 'Enter Unique Number')
        }  
    stages {
            stage('Build') {
            agent { node {  label 'Build'  } }
            steps {
               script {
               sh build.sh
                    }
                }

            stage('Deploy') {
            agent { node {  label 'Deploy'  } }
            steps {
               script {
               sh deploy.sh
                    }
                }

            stage('Test') {
            agent { node {  label 'Test'  } }
            steps {
               script {
               sh test.sh
                    }
                }

           }
         }

我只是多次使用不同的唯一ID号作为输入参数触发了该作业多次.因此,结果是我将在不同阶段对此作业进行多次运行/构建.

I just trigger this job multiple times with different unique ID number as input parameter. So as a result i will have multiple run/build for this job at different stages.

为此,我需要触发多个运行/构建,以将其作为单个构建升级到该管道作业中的下一个阶段(即,从构建到部署或从部署到测试).而不是触发每个运行/构建进入下一阶段.有可能吗?

With this, i need to trigger a multiple run/build to be promote to next stage (i.e., from build to deploy or from deploy to test) in this pipeline job as a one single build instead of triggering each and every single run/build to next stage. Is there any possibility?

推荐答案

如果运行以下命令,则可以从一个管道中启动多个作业:

You can start multiple jobs from one pipeline if you run something as:

build job:"One", wait: false
build job:"Two", wait: false

您的主要工作是启动子管道,子管道将并行运行.

Your main job starts children pipelines and children pipelines will run in parallel.

您可以阅读 PipeLine构建步骤文档以获取更多信息.

此外,您还可以阅读有关在声明式管道中并行运行的信息

Also, you can read about the parallel run in declarative pipeline

此处,您可以找到很多并行运行的示例

Here you can find a lot of examples for parallel running

这篇关于如何在詹金斯的单个管道作业中触发多次运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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