Reputation: 309
I declared a global variable def my_var in my pipeline script on a node and setting the value for the variable on a node dev and on the downstream job(which is running on a different node-test) I'm trying to access the my_var value
Upstream Job:
def my_var
pipeline {
agent none;
parameters {
string(defaultValue: "${CHANGE_BRANCH}", description: 'This is a parameter', name: 'PARAMETER01')
}
stages {
stage('PR'){
agent {node 'dev'}
steps{
script{
my_var = "${env.PARAMETER01}"
}
build job: 'PR-Job', parameters: [text(name: 'testParam', value: "${my_var}")]
}
}
}
Downstream Job(PR-Job):
pipeline {
agent none;
stages {
stage('PrintParameter'){
agent {node 'test'}
steps{
sh "echo ${testParam}"
}
}
Upvotes: 1
Views: 457
Reputation: 6889
You seem to have forgotten to add the parameter to your downstream job.
pipeline {
parameters {
string(name: 'testParam', defaultValue: '', description: '')
}
...
}
Upvotes: 2