Bird
Raised Fist0
Jenkinsdevops~10 mins

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

Choose your learning style10 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.

Practice

(1/5)
1. What is the main purpose of using pipeline triggers in Jenkins?
easy
A. To delete old job logs automatically
B. To manually run jobs one by one
C. To stop all jobs from running
D. To automatically start a job when another job finishes

Solution

  1. Step 1: Understand pipeline triggers

    Pipeline triggers are used to start one job automatically after another job finishes.
  2. Step 2: Identify the purpose

    This automation helps connect jobs without manual intervention.
  3. Final Answer:

    To automatically start a job when another job finishes -> Option D
  4. Quick Check:

    Pipeline triggers = automatic job start [OK]
Hint: Triggers start jobs automatically after others finish [OK]
Common Mistakes:
  • Thinking triggers run jobs manually
  • Confusing triggers with log cleanup
  • Believing triggers stop jobs
2. Which syntax correctly triggers a downstream job named Build-App after the current pipeline completes successfully?
easy
A. build job: 'Build-App', propagate: true, wait: true
B. trigger job: 'Build-App' onSuccess
C. start job 'Build-App' after success
D. run job 'Build-App' always

Solution

  1. Step 1: Recall Jenkins pipeline syntax for triggering jobs

    The correct syntax uses the build step with parameters like job, propagate, and wait.
  2. Step 2: Match the correct syntax

    build job: 'Build-App', propagate: true, wait: true matches the correct syntax exactly.
  3. Final Answer:

    build job: 'Build-App', propagate: true, wait: true -> Option A
  4. Quick Check:

    Correct build step syntax = build job: 'Build-App', propagate: true, wait: true [OK]
Hint: Use 'build job:' syntax to trigger downstream jobs [OK]
Common Mistakes:
  • Using incorrect keywords like 'trigger' or 'start'
  • Missing required parameters
  • Wrong order or syntax errors
3. Given this Jenkins pipeline snippet:
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
    stage('Trigger Test') {
      steps {
        build job: 'Test-Job', propagate: true, wait: true
      }
    }
  }
}

What happens when the 'Build' stage completes successfully?
medium
A. 'Test-Job' runs in parallel without waiting
B. The 'Test-Job' pipeline starts and Jenkins waits for it to finish
C. The pipeline stops after 'Build' stage
D. An error occurs because 'build' is not a valid step

Solution

  1. Step 1: Understand the 'build' step with 'wait: true'

    The 'build' step triggers another job and waits for it to complete before continuing.
  2. Step 2: Analyze the pipeline flow

    After 'Build' stage, 'Test-Job' starts and Jenkins waits for it to finish before moving on.
  3. Final Answer:

    The 'Test-Job' pipeline starts and Jenkins waits for it to finish -> Option B
  4. Quick Check:

    'build' with wait=true means wait for downstream job [OK]
Hint: Wait true means wait for downstream job to finish [OK]
Common Mistakes:
  • Assuming downstream runs in parallel without waiting
  • Thinking pipeline stops early
  • Believing 'build' is invalid step
4. You have this pipeline snippet:
build job: 'Deploy-App', propagate: false, wait: true

What issue might occur if 'Deploy-App' fails?
medium
A. Jenkins throws a syntax error
B. The current pipeline stops immediately on failure
C. The current pipeline continues despite failure in 'Deploy-App'
D. 'Deploy-App' runs twice

Solution

  1. Step 1: Understand 'propagate: false'

    This setting means the failure of the downstream job does not fail the current pipeline.
  2. Step 2: Analyze failure behavior

    If 'Deploy-App' fails, the current pipeline will continue running instead of stopping.
  3. Final Answer:

    The current pipeline continues despite failure in 'Deploy-App' -> Option C
  4. Quick Check:

    propagate false = ignore downstream failure [OK]
Hint: propagate false lets pipeline ignore downstream failures [OK]
Common Mistakes:
  • Assuming pipeline stops on downstream failure
  • Confusing propagate with wait
  • Expecting syntax errors
5. You want to create a Jenkins pipeline where Job A triggers Job B only if Job A succeeds, and Job B triggers Job C regardless of its result. Which configuration correctly achieves this?
hard
A. In Job A pipeline: build job: 'Job-B', propagate: true, wait: true
In Job B pipeline: build job: 'Job-C', propagate: false, wait: false
B. In Job A pipeline: build job: 'Job-B', propagate: false, wait: false
In Job B pipeline: build job: 'Job-C', propagate: true, wait: true
C. In Job A pipeline: build job: 'Job-B', propagate: true, wait: false
In Job B pipeline: build job: 'Job-C', propagate: true, wait: true
D. In Job A pipeline: build job: 'Job-B', propagate: false, wait: true
In Job B pipeline: build job: 'Job-C', propagate: false, wait: true

Solution

  1. Step 1: Ensure Job B triggers only on Job A success

    Using propagate: true in Job A means failure in Job B will fail Job A, so Job B runs only if Job A succeeds.
  2. Step 2: Ensure Job C triggers regardless of Job B result

    Using propagate: false and wait: false in Job B triggers Job C without waiting and ignores Job C's result.
  3. Final Answer:

    Option A matches these requirements -> Option A
  4. Quick Check:

    propagate true for success-only triggers, false for unconditional [OK]
Hint: Use propagate true for success-only, false for unconditional triggers [OK]
Common Mistakes:
  • Using propagate false when success-only is needed
  • Confusing wait true/false effects
  • Triggering downstream jobs incorrectly
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard