0
0
Jenkinsdevops~20 mins

Hybrid CI/CD approaches in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Hybrid CI/CD Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Hybrid CI/CD Pipelines

In a hybrid CI/CD approach, which of the following best describes the main advantage?

AIt combines on-premises and cloud resources to optimize build and deployment speed.
BIt uses only cloud resources to reduce costs and complexity.
CIt requires manual intervention at every stage to ensure quality.
DIt eliminates the need for version control systems.
Attempts:
2 left
💡 Hint

Think about how hybrid approaches balance different environments.

💻 Command Output
intermediate
2:00remaining
Jenkins Pipeline Output with Hybrid Agents

Given this Jenkinsfile snippet using hybrid agents:

pipeline {
  agent none
  stages {
    stage('Build') {
      agent { label 'on-prem-agent' }
      steps {
        echo 'Building on on-premises agent'
      }
    }
    stage('Deploy') {
      agent { label 'cloud-agent' }
      steps {
        echo 'Deploying on cloud agent'
      }
    }
  }
}

What will be the console output when this pipeline runs?

Jenkins
pipeline {
  agent none
  stages {
    stage('Build') {
      agent { label 'on-prem-agent' }
      steps {
        echo 'Building on on-premises agent'
      }
    }
    stage('Deploy') {
      agent { label 'cloud-agent' }
      steps {
        echo 'Deploying on cloud agent'
      }
    }
  }
}
AError: Agent label 'on-prem-agent' not found
B[Pipeline] stage\n[Pipeline] { (Build)\nDeploying on cloud agent\n[Pipeline] }\n[Pipeline] stage\n[Pipeline] { (Deploy)\nBuilding on on-premises agent\n[Pipeline] }
C[Pipeline] stage\n[Pipeline] { (Build)\nBuilding on on-premises agent\n[Pipeline] }\n[Pipeline] stage\n[Pipeline] { (Deploy)\nDeploying on cloud agent\n[Pipeline] }
DError: Agent label 'cloud-agent' not found
Attempts:
2 left
💡 Hint

Each stage uses its own agent label to run steps.

Configuration
advanced
2:30remaining
Configuring Jenkins for Hybrid CI/CD

Which Jenkins configuration snippet correctly sets up a hybrid pipeline that uses a Docker container on a cloud agent for testing and an on-premises agent for building?

A
pipeline {
  agent none
  stages {
    stage('Build') {
      agent { docker { image 'python:3.12' label 'on-prem-agent' } }
      steps {
        sh 'make build'
      }
    }
    stage('Test') {
      agent { label 'cloud-agent' }
      steps {
        sh 'pytest'
      }
    }
  }
}
B
pipeline {
  agent none
  stages {
    stage('Build') {
      agent { label 'on-prem-agent' }
      steps {
        sh 'make build'
      }
    }
    stage('Test') {
      agent {
        docker {
          image 'python:3.12'
          label 'cloud-agent'
        }
      }
      steps {
        sh 'pytest'
      }
    }
  }
}
C
pipeline {
  agent { label 'cloud-agent' }
  stages {
    stage('Build') {
      steps {
        sh 'make build'
      }
    }
    stage('Test') {
      agent { docker { image 'python:3.12' } }
      steps {
        sh 'pytest'
      }
    }
  }
}
D
pipeline {
  agent {
    docker {
      image 'python:3.12'
      label 'on-prem-agent'
    }
  }
  stages {
    stage('Build') {
      steps {
        sh 'make build'
      }
    }
    stage('Test') {
      agent { label 'cloud-agent' }
      steps {
        sh 'pytest'
      }
    }
  }
}
Attempts:
2 left
💡 Hint

Remember that Docker agent inside a stage requires both image and label separately.

Troubleshoot
advanced
2:00remaining
Troubleshooting Hybrid Pipeline Agent Errors

A Jenkins hybrid pipeline fails with the error: java.lang.IllegalArgumentException: No agent found with label 'cloud-agent'. What is the most likely cause?

AThe label 'cloud-agent' is not assigned to any active Jenkins agent node.
BThe Jenkins master node is offline, causing all agents to be unreachable.
CThe pipeline syntax is incorrect and missing the 'agent' block entirely.
DThe Docker image specified for the cloud agent is invalid or missing.
Attempts:
2 left
💡 Hint

Check the agent labels configured in Jenkins nodes.

🔀 Workflow
expert
3:00remaining
Hybrid CI/CD Workflow Optimization

You have a hybrid CI/CD setup where builds run on-premises and deployments run in the cloud. Which workflow change will best reduce deployment downtime during updates?

AUse manual approval steps before deployment to ensure no errors occur.
BMove all builds and deployments to the on-premises environment to reduce network latency.
CRun builds and deployments simultaneously on both on-premises and cloud agents.
DImplement blue-green deployment in the cloud environment while keeping builds on-premises.
Attempts:
2 left
💡 Hint

Think about deployment strategies that minimize downtime.