How to trigger a Jenkins pipeline A in another Jenkins pipeline B?

0 votes
I’ve created two Jenkins pipeline, let’s say pipelineA and pipelineB. I want to invoke pipelineA in pipelineB. How can this be done?
Jul 5, 2018 in Jenkins by Tyrion anex
• 8,270 points
4,169 views

2 answers to this question.

0 votes

You can run the following code, its an example of running pipelineA in pipeline.

Make sure you’ve created a ‘pipelineA’ before running this code.

pipeline {
agent
    {
        node {
                label 'master'
                customWorkspace "${env.JobPath}"
              }
    }
    stages 
    {
        stage('Start') {
            steps {
                echo 'Hello'
            }
        }
        stage ('Invoke_pipelineA') {
            steps {
                build job: 'pipelineA', parameters: [
                string(name: 'param1', value: "value1")
                ]
            }
        }
        stage('End') {
            steps {
                echo 'Bye'
            }
        }
    }
}
answered Jul 5, 2018 by Sophie may
• 9,530 points
I think the question was to trigger a pipeline from another jenkins.
I think what @Tyrion meant is that he has two pipelines on same Jenkins and would like to invoke pipeline in pipelineB
0 votes

If you are talking about executing another pipeline job, the "build job" step can accomplish this:

build job: '<Project name>', propagate: true, wait: true

propagate: Propagate errors

wait: Wait for completion

If you have paramters on the job, you can add them like this:

build job: '<Project name>', parameters: [[$class: 'StringParameterValue', name: 'param1', value: 'test_param']]
answered Jul 31 by Sirajul
• 25,420 points

Related Questions In Jenkins

0 votes
2 answers
0 votes
2 answers

How to auto build a job in jenkins if there is any change in code on Github repository?

To automatically run build on code commit, follow ...READ MORE

answered Jul 31 in Jenkins by Sirajul
• 25,420 points
136 views
0 votes
2 answers

how to execute a shell script post build step in Jenkins?

You could use the Post Build Task Plugin ...READ MORE

answered Jul 31 in Jenkins by Sirajul
• 25,420 points
86 views
+1 vote
1 answer

How to extract a substring of a string in a declarative pipeline code?

This would have been more easier using ...READ MORE

answered Aug 16 in Jenkins by Sirajul
• 25,420 points
72 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
147 views
0 votes
1 answer
0 votes
2 answers

How to get the Maven Version of a project in Jenkins?

Since the groovy script is a bit complex ...READ MORE

answered Jul 31 in Jenkins by Sirajul
• 25,420 points
915 views
0 votes
2 answers

How to start Jenkins on a different port rather than 8080?

In case you want to change the ...READ MORE

answered Jul 31 in Jenkins by Sirajul
• 25,420 points
1,441 views