How to pass parameters in downstream jenkins jobs

I got a question how to pass parameter in trailing jobs. Jenkins 2.0 provides option to use Jenkinsfile.

  1. Takes in parameter “Task_Name”
  2. Runs Job-1 and pass in parameter “Task_Name” to it
  3. Upon successful run of Job-1, it will trigger Job-2 and pass in the “Task_Name” parameter
  4. Note that Job-1 and Job-2 are 2 separate Jenkins jobs, and the Jenkinsfile below belongs to the Jenkins job that triggers both Job-1 and Job-2

 

pipeline {
	agent any
	parameters {
		string(name: 'Task_Name', defaultValue: 'Testing', description: 'Name of the task')
	}
	stages {
		stage('job 1'){

			 steps {
                echo "${params.Task_Name} Job 1!"
            }
		}
		stage('job 2'){

			 steps {
                echo "${params.Task_Name} Job 2!"
            }
		}
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *