Pipeline - How to write a declarative pipeline to invoke another job

Issue

  • I want a sample code of Declarative Pipeline which invokes another job

Environment

Resolution

pipeline {				//indicate the job is written in Declarative Pipeline
    agent any				//agent specifies where the pipeline will execute. 
    stages {
        stage ("build") {		//an arbitrary stage name
            steps {
                build 'Pipeline_B'	//this is where we specify which job to invoke.
            }
        }
    }
}

You can use the Snippet Generator from Jenkins to generate the pipeline code. Snippet Generator can be accessed from ${JENKINS_HOME}/pipeline-syntax/

Note:

  • The build step can be used to call any project. The job which will be triggered does not have to be a pipeline.
  • You can pass additional build parameters as documented in Pipeline Build Step

Tested product/plugin versions

Reference

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.