Passing Values from one job to another job in Jenkins
Vijesh Vijayan
1 min read
Objective:
Suppose there are two pipelines A and B. I want to create any value in Pipeline A and pass to another job Pipeline B as a parameter.
Pipeline A:
pipeline {
agent any
stages{
stage("Build"){
steps{
script{
def output= 'This is a parameter from Pipeline A'
build job: 'Pipeline B', parameters: [string(name:'PassValue', value: output)]
}
}
}
}
}
Pipeline B:
pipeline {
agent any
parameters{
string(name:'PassValue',defaultValue:'',description:'Passed from upstream job')
}
stages {
stage('Build') {
steps {
script{
echo "Passed Value from Pipeline A: ${params.PassValue}"
}
}
}
}
}
Now trigger the Pipeline A:
As seen above the value is passed from Job: Pipeline A to Job: Pipeline B as parameters. Thanks…
0
Subscribe to my newsletter
Read articles from Vijesh Vijayan directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Vijesh Vijayan
Vijesh Vijayan
An Experienced IT Professional with a curiosity in learning and sharing knowledge.