Reputation: 49
Let's say I have a pipeline with a run parameters like this:
downstreamJob:
pipeline {
parameters {
run(name: 'NAME', filter: 'STABLE', projectName: 'myProject)
}
}
Now, how can I use this job from another job and pass a run parameter?
Main job:
pipeline {
parameters {
run(name: 'NAME', filter: 'STABLE', projectName: 'myProject)
}
stages {
stage('stage 1') {
steps {
build(job: "downstreamJob",
parameters: [
run(name: 'NAME', value: NAME)])
}
}
}
}
Error:
WARNING: Unknown parameter(s) found for class type 'hudson.model.RunParameterValue': value
Could not instantiate {job=downstreamJob, parameters=[@run(name=NAME,value=http://.....)]} for org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerStep: java.lang.IllegalArgumentException: Could not instantiate {name=NAME, value=http://.....} for hudson.model.RunParameterValue: java.lang.reflect.InvocationTargetException
Upvotes: 2
Views: 3923
Reputation: 49
Solution was to call the downstream job with:
run(name: 'NAME', runId: NAME_JOBNAME + NAME_NUMBER)
They are environment variables and runID will be in the format: myProject#0
Upvotes: 1