0
0
Jenkinsdevops~10 mins

Cloud agent provisioning (EC2, Azure) in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Cloud agent provisioning (EC2, Azure)
Start Jenkins Job
Select Cloud Provider
Provision EC2
Configure Agent
Agent Ready for Job Execution
Run Job
Cleanup
End
This flow shows Jenkins starting a job, choosing a cloud provider (EC2 or Azure), provisioning the agent, configuring it, running the job, and cleaning up.
Execution Sample
Jenkins
pipeline {
  agent {
    label 'ec2-agent'
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building on EC2 agent'
      }
    }
  }
}
This Jenkins pipeline provisions an EC2 cloud agent labeled 'ec2-agent' and runs a build stage on it.
Process Table
StepActionEvaluationResult
1Start Jenkins jobJob triggeredJob starts execution
2Select cloud providerProvider = AWS EC2EC2 provisioning begins
3Provision EC2 instanceRequest EC2 instance with label 'ec2-agent'EC2 instance launched and connected
4Configure agentInstall Jenkins agent on EC2Agent ready and connected to Jenkins master
5Run build stageExecute echo commandOutput: 'Building on EC2 agent'
6Job completesBuild stage finishedJob ends successfully
7CleanupTerminate EC2 instanceEC2 instance terminated
8ExitNo more stagesJob fully completed
💡 Job ends after build stage completes and EC2 instance is terminated.
Status Tracker
VariableStartAfter Step 3After Step 4After Step 7Final
cloud_providernullAWS EC2AWS EC2AWS EC2null
agent_statusnot provisionedprovisioningreadyterminatingterminated
job_statusnot startedrunningrunningcompletedcompleted
Key Moments - 2 Insights
Why does the agent_status change from 'provisioning' to 'ready' after step 4?
Because after the EC2 instance is launched (step 3), Jenkins installs and connects the agent software on it (step 4), making the agent ready to run jobs as shown in execution_table row 4.
Why is the EC2 instance terminated after the job completes?
To save costs and resources, Jenkins cleans up by terminating the EC2 instance after the job finishes, as shown in execution_table step 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the agent_status after step 4?
Aprovisioning
Bready
Cterminated
Dnot provisioned
💡 Hint
Check the variable_tracker table under 'agent_status' after Step 4.
At which step does the EC2 instance get terminated?
AStep 7
BStep 6
CStep 5
DStep 8
💡 Hint
Look at the execution_table row describing cleanup and termination.
If the cloud_provider was changed to Azure, which step would change in the execution table?
AStep 4
BStep 3
CStep 2
DStep 5
💡 Hint
Step 2 is where the cloud provider is selected.
Concept Snapshot
Jenkins Cloud Agent Provisioning:
- Define cloud provider in pipeline (e.g., AWS EC2 or Azure VM).
- Jenkins requests and launches cloud VM as agent.
- Agent installs Jenkins software and connects.
- Job runs on this dynamic agent.
- After job, agent VM is terminated to save cost.
Full Transcript
This visual execution shows how Jenkins provisions cloud agents on EC2 or Azure. The job starts, selects a cloud provider, provisions the VM, configures the Jenkins agent, runs the job, and then cleans up by terminating the VM. Variables like agent_status and job_status change step-by-step. Key moments include understanding when the agent becomes ready and why cleanup happens. The quiz tests knowledge of these steps and variable states.