How do you trigger one Jenkins job from another and pass data?
BeginnerConceptJenkins
Answer
Use the build step. wait: true (default) blocks until the downstream finishes; propagate: false stops a downstream failure from failing the caller.
def result = build job: 'deploy-app', parameters: [
string(name: 'VERSION', value: env.GIT_COMMIT)
], wait: true
echo "Downstream: ${result.result}"
For complex flows, we prefer a single pipeline with stages over chains of jobs, since job chains are hard to follow and reproduce.
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate