Bird
Raised Fist0
Jenkinsdevops~10 mins

Hybrid CI/CD approaches in Jenkins - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Hybrid CI/CD approaches
Code Commit
↓
Trigger CI Pipeline
↓
Build & Test
↓
Decision: Auto Deploy or Manual Approval?
↓
Auto Deploy
↓
Deploy to Prod
↓
Deploy to Prod
Code is committed, triggering CI build and tests. Then deployment can be automatic or wait for manual approval before deploying.
Execution Sample
Jenkins
pipeline {
  agent any
  parameters {
    booleanParam(name: 'AUTO_DEPLOY', defaultValue: false, description: 'Automatically deploy after build')
  }
  stages {
    stage('Build & Test') {
      steps { echo 'Building and Testing...' }
    }
    stage('Deploy') {
      steps {
        script {
          if (params.AUTO_DEPLOY) {
            echo 'Deploying automatically'
          } else {
            input 'Approve Deployment?'
            echo 'Deploying after approval'
          }
        }
      }
    }
  }
}
Jenkins pipeline that builds and tests code, then deploys automatically or waits for manual approval based on a parameter.
Process Table
StepActionConditionResultOutput
1Code commit triggers pipelineN/APipeline startsBuild & Test stage begins
2Build & Test stage runsN/ABuild and tests succeedOutput: 'Building and Testing...'
3Check AUTO_DEPLOY parameterAUTO_DEPLOY == true?True branchOutput: 'Deploying automatically'
4Deploy stage completesN/ADeployment done automaticallyPipeline ends
5Alternative: AUTO_DEPLOY == falseFalse branchWait for manual approvalPipeline pauses for input
6Manual approval givenN/ADeployment proceedsOutput: 'Deploying after approval'
7Deploy stage completesN/ADeployment done after approvalPipeline ends
💡 Pipeline ends after deployment either automatically or after manual approval.
Status Tracker
VariableStartAfter Step 3After Step 5Final
AUTO_DEPLOYundefinedtrue or false (depends on param)false (if manual approval path)true or false (final deployment path)
Key Moments - 2 Insights
Why does the pipeline pause at step 5?
At step 5, if AUTO_DEPLOY is false, the pipeline waits for manual approval using the input step, pausing execution until approval is given (see execution_table row 5).
What happens if AUTO_DEPLOY is true?
If AUTO_DEPLOY is true at step 3, the pipeline skips manual approval and deploys automatically (execution_table row 3 and 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what output appears at step 2?
A'Deploying automatically'
B'Approve Deployment?'
C'Building and Testing...'
D'Deploying after approval'
💡 Hint
Check the 'Output' column for step 2 in the execution_table.
At which step does the pipeline wait for manual approval?
AStep 5
BStep 3
CStep 6
DStep 7
💡 Hint
Look for the step where the pipeline pauses for input in the execution_table.
If AUTO_DEPLOY is set to false, what is the output at step 6?
A'Deploying automatically'
B'Deploying after approval'
C'Building and Testing...'
D'Pipeline ends'
💡 Hint
Refer to the output column at step 6 in the execution_table.
Concept Snapshot
Hybrid CI/CD pipelines combine automatic and manual deployment steps.
Code commit triggers build and test stages.
Deployment can be automatic or wait for manual approval.
Use parameters to control deployment flow.
Manual approval pauses pipeline until confirmed.
This approach balances speed and control.
Full Transcript
In hybrid CI/CD approaches, when code is committed, the pipeline starts by building and testing the code. After successful tests, the pipeline decides whether to deploy automatically or wait for manual approval based on a parameter called AUTO_DEPLOY. If AUTO_DEPLOY is true, deployment happens immediately. If false, the pipeline pauses and waits for a human to approve before deploying. This method combines fast automation with safety checks. The Jenkins pipeline example shows these steps clearly, with outputs indicating each stage's progress. Variables like AUTO_DEPLOY control the flow, and the pipeline ends after deployment completes either way.

Practice

(1/5)
1. What is the main purpose of using a hybrid CI/CD approach in Jenkins pipelines?
easy
A. To combine automatic and manual steps for safer deployments
B. To run only manual deployment steps without automation
C. To automate all steps without any manual intervention
D. To disable pipeline triggers and run jobs manually

Solution

  1. Step 1: Understand hybrid CI/CD concept

    Hybrid CI/CD mixes automatic and manual steps to balance speed and control.
  2. Step 2: Identify Jenkins pipeline usage

    Jenkins pipelines use the input step to pause for manual approval, enabling safer deployments.
  3. Final Answer:

    To combine automatic and manual steps for safer deployments -> Option A
  4. Quick Check:

    Hybrid CI/CD = mix auto + manual [OK]
Hint: Hybrid means mixing auto and manual steps [OK]
Common Mistakes:
  • Thinking hybrid means fully manual
  • Assuming hybrid means fully automated
  • Confusing hybrid with disabling triggers
2. Which Jenkins pipeline syntax correctly adds a manual approval step?
easy
A. manualApproval('Approve deployment?')
B. input message: 'Approve deployment?'
C. pause('Approve deployment?')
D. waitForInput('Approve deployment?')

Solution

  1. Step 1: Recall Jenkins input step syntax

    The input step pauses the pipeline and asks for manual approval with a message.
  2. Step 2: Match syntax to options

    Only input message: 'Approve deployment?' is valid Jenkins pipeline syntax for manual input.
  3. Final Answer:

    input message: 'Approve deployment?' -> Option B
  4. Quick Check:

    Jenkins manual step = input message [OK]
Hint: Use 'input message:' for manual approval in Jenkins [OK]
Common Mistakes:
  • Using non-existent commands like manualApproval
  • Confusing input with pause or waitForInput
  • Missing the 'message:' keyword
3. Given this Jenkins pipeline snippet, what happens when it runs?
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
    stage('Deploy') {
      steps {
        input message: 'Approve deployment?'
        echo 'Deploying...'
      }
    }
  }
}
medium
A. Pipeline fails because input step is invalid
B. Build and deploy run automatically without pause
C. Deploy runs first, then build runs after approval
D. Build runs, then pipeline waits for manual approval before deploying

Solution

  1. Step 1: Analyze pipeline stages order

    Stages run in order: 'Build' first, then 'Deploy'.
  2. Step 2: Understand input step effect

    The input step pauses the pipeline and waits for manual approval before continuing to echo 'Deploying...'.
  3. Final Answer:

    Build runs, then pipeline waits for manual approval before deploying -> Option D
  4. Quick Check:

    input pauses pipeline for approval [OK]
Hint: Input pauses pipeline until manual approval [OK]
Common Mistakes:
  • Assuming deploy runs automatically without pause
  • Thinking input step causes failure
  • Confusing stage order
4. You added this input step in your Jenkins pipeline but it never pauses for approval:
input 'Approve deployment?'

What is the likely problem?
medium
A. The input step requires a named parameter like message: to work
B. The input step must be inside a script block
C. The input step only works in declarative pipelines
D. The input step needs a timeout parameter

Solution

  1. Step 1: Check input step syntax

    The input step requires named parameters like message: 'text' for proper execution.
  2. Step 2: Identify missing named parameter

    Using just a string without message: causes Jenkins to ignore the input step and not pause.
  3. Final Answer:

    The input step requires a named parameter like message: to work -> Option A
  4. Quick Check:

    Input needs message: parameter [OK]
Hint: Always use 'message:' with input step [OK]
Common Mistakes:
  • Omitting message: parameter
  • Thinking input must be in script block
  • Assuming timeout is mandatory
5. You want a Jenkins pipeline that builds automatically, then waits for manual approval, and finally deploys only if approved within 10 minutes. Which snippet correctly implements this hybrid CI/CD approach?
hard
A. timeout(time: 10, unit: MINUTES) { input message: 'Approve deployment?' } echo 'Deploying...'
B. input message: 'Approve deployment?', timeout: 10, unit: 'MINUTES' if (currentBuild.result != 'ABORTED') { echo 'Deploying...' }
C. timeout(time: 10, unit: 'MINUTES') { input message: 'Approve deployment?' echo 'Deploying...' }
D. input message: 'Approve deployment?', timeout: 10, unit: 'MINUTES' echo 'Deploying...'

Solution

  1. Step 1: Understand timeout with input step

    To limit approval wait time, wrap input and deployment steps inside a timeout block.
  2. Step 2: Check which option wraps input and deploy inside timeout

    timeout(time: 10, unit: 'MINUTES') { input message: 'Approve deployment?' echo 'Deploying...' } wraps both input and echo 'Deploying...' inside timeout, ensuring deploy runs only if approved within 10 minutes.
  3. Final Answer:

    timeout(time: 10, unit: 'MINUTES') { input message: 'Approve deployment?' echo 'Deploying...' } -> Option C
  4. Quick Check:

    Timeout wraps input and deploy steps [OK]
Hint: Wrap input and deploy in timeout block [OK]
Common Mistakes:
  • Not wrapping deploy inside timeout
  • Checking build result incorrectly
  • Using timeout only around input without deploy
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