0
0
Jenkinsdevops~5 mins

Hybrid CI/CD approaches in Jenkins - Commands & Configuration

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