如何在另一个詹金斯管道 B 中调用詹金斯管道 A [英] How to invoke a jenkins pipeline A in another jenkins pipeline B

查看:38
本文介绍了如何在另一个詹金斯管道 B 中调用詹金斯管道 A的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两条 Jenkins 管道,假设管道 A 和管道 B.我想在管道 B 中调用管道 A.我怎样才能做到这一点?

I have two Jenkins pipelines, let's say pipeline-A and pipeline-B. I want to invoke pipeline-A in pipeline-B. How can I do this?

(pipeline-A 是pipeline-B 的一个子集.Pipeline-A 负责做一些可以在pipeline-B 中重复使用的例行工作)

(pipeline-A is a subset of pipeline-B. Pipeline-A is responsible for doing some routine stuff which can be reused in pipeline-B)

我已经在我的机器上安装了 Jenkins 2.41.

I have installed Jenkins 2.41 on my machine.

推荐答案

以下解决方案适用于我:

Following solution works for me:

pipeline {
    agent
    {
        node {
                label 'master'
                customWorkspace "${env.JobPath}"
              }
    }

    stages 
    {
        stage('Start') {
            steps {
                sh 'ls'
            }
        }

        stage ('Invoke_pipeline') {
            steps {
                build job: 'pipeline1', parameters: [
                string(name: 'param1', value: "value1")
                ]
            }
        }

        stage('End') {
            steps {
                sh 'ls'
            }
        }
    }
}

在此处添加Pipeline: Build Step"官方文档的链接:https://jenkins.io/doc/pipeline/steps/pipeline-build-步骤/

Adding link of the official documentation of "Pipeline: Build Step" here: https://jenkins.io/doc/pipeline/steps/pipeline-build-step/

这篇关于如何在另一个詹金斯管道 B 中调用詹金斯管道 A的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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