0
0
Jenkinsdevops~10 mins

Pipeline triggers and upstream/downstream in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Pipeline triggers and upstream/downstream
Upstream Job completes
Trigger Downstream Job
Downstream Job starts
Downstream Job completes
Pipeline chain ends
This flow shows how one Jenkins job (upstream) triggers another job (downstream) after it finishes, creating a chain of jobs.
Execution Sample
Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps { echo 'Building...' }
    }
  }
  post {
    success { build job: 'DownstreamJob' }
  }
}
A Jenkins pipeline that runs a build stage and triggers a downstream job when successful.
Process Table
StepEventActionJob StateTriggered Job
1Start Upstream JobBegin pipeline executionUpstream: RunningNone
2Build StageExecute build stepsUpstream: RunningNone
3Build SuccessPost success block triggersUpstream: SuccessDownstreamJob triggered
4Downstream Job StartDownstream job beginsDownstream: RunningNone
5Downstream Job CompleteDownstream job finishesDownstream: SuccessNone
6Pipeline Chain EndAll jobs completedAll: SuccessNone
💡 Downstream job completes successfully, ending the pipeline chain.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 5Final
Upstream Job StateNot startedRunningSuccessSuccessSuccess
Downstream Job StateNot startedNot startedTriggeredSuccessSuccess
Key Moments - 2 Insights
Why does the downstream job only start after the upstream job succeeds?
Because the trigger is inside the 'post { success { ... } }' block, it runs only when the upstream job finishes successfully, as shown in execution_table row 3.
Can the downstream job start if the upstream job fails?
No, the downstream job trigger is inside the success block, so it won't run if the upstream job fails. This is clear from the absence of triggering in failure scenarios.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the downstream job start running?
AStep 3
BStep 4
CStep 2
DStep 5
💡 Hint
Check the 'Job State' and 'Event' columns in execution_table row 4.
According to variable_tracker, what is the state of the downstream job after step 3?
ATriggered
BNot started
CRunning
DSuccess
💡 Hint
Look at the 'Downstream Job State' row under 'After Step 3' in variable_tracker.
If the upstream job fails, what happens to the downstream job trigger in this pipeline?
ADownstream job triggers anyway
BDownstream job triggers only if manually started
CDownstream job does not trigger
DPipeline retries upstream job automatically
💡 Hint
Refer to key_moments explanation about the 'post { success { ... } }' block.
Concept Snapshot
Jenkins pipelines can trigger downstream jobs after upstream jobs finish.
Use 'post { success { build job: "JobName" } }' to trigger only on success.
Upstream job runs first, then downstream job starts automatically.
This creates a chain of jobs for complex workflows.
Full Transcript
This visual execution shows how Jenkins pipelines trigger downstream jobs after upstream jobs complete successfully. The upstream job runs its stages, then in the post success block, it triggers the downstream job. The downstream job starts only after the upstream job finishes successfully, creating a chain of jobs. Variables track job states changing from not started to running to success. Key moments clarify that downstream jobs do not trigger if the upstream job fails. The quiz tests understanding of when downstream jobs start and how triggers depend on upstream job results.