Bird
Raised Fist0
Jenkinsdevops~5 mins

Hybrid CI/CD approaches in Jenkins - Commands & Configuration

Choose your learning style10 modes available
Introduction
Hybrid CI/CD combines different methods of building, testing, and deploying software to get the best of both worlds. It helps teams use both automated pipelines and manual steps where needed to keep control and speed.
When you want to automate most of your software delivery but keep manual approval for critical steps like production deployment.
When your team uses different tools or environments that require mixing scripted pipelines with manual tasks.
When you need to run some tests automatically but want to review results before continuing.
When you want to deploy to multiple environments with different rules, some automatic and some manual.
When you want to gradually move from manual releases to fully automated pipelines.
Config File - Jenkinsfile
Jenkinsfile
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building the application'
        sh 'make build'
      }
    }
    stage('Test') {
      steps {
        echo 'Running tests'
        sh 'make test'
      }
    }
    stage('Approval') {
      steps {
        input message: 'Approve deployment to production?', ok: 'Deploy'
      }
    }
    stage('Deploy') {
      steps {
        echo 'Deploying to production'
        sh 'make deploy'
      }
    }
  }
}

This Jenkinsfile defines a pipeline with four stages:

  • Build: Compiles or prepares the application.
  • Test: Runs automated tests.
  • Approval: Pauses the pipeline and waits for a manual approval before continuing.
  • Deploy: Deploys the application after approval.

This mix of automated and manual steps is the core of hybrid CI/CD.

Commands
This command updates the Jenkins job configuration with the new Jenkinsfile to set up the hybrid pipeline.
Terminal
jenkins-jobs --conf jenkins.ini update my-pipeline
Expected OutputExpected
Job 'my-pipeline' updated successfully
→
--conf - Specifies the Jenkins configuration file to use
Starts the pipeline job in Jenkins to run the build and test stages automatically.
Terminal
jenkins-cli build my-pipeline
Expected OutputExpected
Started build #1 for job 'my-pipeline'
Manually approves the deployment stage after reviewing test results, allowing the pipeline to continue.
Terminal
jenkins-cli input my-pipeline #1 'Approve deployment to production?'
Expected OutputExpected
Input 'Approve deployment to production?' approved for build #1
Shows the console output of the pipeline run to verify all stages completed successfully.
Terminal
jenkins-cli console my-pipeline #1
Expected OutputExpected
[Pipeline] Start of Pipeline [Pipeline] echo Building the application [Pipeline] sh + make build [Pipeline] echo Running tests [Pipeline] sh + make test [Pipeline] input Waiting for user input: Approve deployment to production? [Pipeline] echo Deploying to production [Pipeline] sh + make deploy [Pipeline] End of Pipeline Finished: SUCCESS
Key Concept

If you remember nothing else from this pattern, remember: hybrid CI/CD mixes automated steps with manual approvals to balance speed and control.

Common Mistakes
Skipping the manual approval step in the Jenkinsfile.
This removes the control point and makes the pipeline fully automatic, losing the hybrid approach benefits.
Always include an input step for manual approval before critical stages like production deployment.
Not updating the Jenkins job after changing the Jenkinsfile.
The pipeline will run the old configuration, so new hybrid steps won't be applied.
Run the job update command to apply Jenkinsfile changes before running the pipeline.
Approving deployment without checking test results.
This can cause broken or untested code to be deployed, risking production stability.
Review test outputs in the console before approving the deployment step.
Summary
Define a Jenkinsfile with automated build and test stages plus a manual approval stage.
Update the Jenkins job to use the new Jenkinsfile configuration.
Run the pipeline to execute automated steps and pause for manual approval.
Approve the deployment manually after reviewing test results to continue the pipeline.
Check the pipeline console output to confirm successful completion.

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