I have a pipeline in Jenkins whose first stage is about triggering another job with the build
function. I want to have the RunWrapper object back from the build function, but it returns a null
object when the wait
paramater is set to false
.
Basically, in this case the build
function returns the correct object type :
stage('Trigger Another Job With Propagate') {
steps {
script {
triggeredJob = build(job: 'Tiggered_Job', wait: true)
echo "${triggeredJob.getClass()}"
// correct object type
}
}
}
But when we don't want to wait the job to finish before stepping into the next stages, a null object is returned :
stage('Trigger Another Job With Propagate') {
steps {
script {
triggeredJob = build(job: 'Tiggered_Job', wait: false)
echo "${triggeredJob.getClass()}"
// null object type
}
}
}
I think that behavior is not normal, we should be able to use the object in any case.