Bird
Raised Fist0
Jenkinsdevops~10 mins

Agent types (permanent, cloud) in Jenkins - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Agent types (permanent, cloud)
Start Jenkins Job
↓
Check Agent Type
↓
Permanent
↓
Use Existing
↓
Agent Node
↓
Run Job
↓
Job Complete
↓
Cloud Agent Cleanup
↓
End
Jenkins decides if the job runs on a permanent or cloud agent, then runs the job accordingly. Cloud agents are created and removed dynamically.
Execution Sample
Jenkins
node('permanent-agent') {
  echo 'Running on permanent agent'
}

node('cloud-agent') {
  echo 'Running on cloud agent'
}
Runs a Jenkins job on either a permanent or a cloud agent node.
Process Table
StepAgent TypeActionAgent StateJob State
1PermanentSelect existing permanent agentAgent readyJob queued
2PermanentRun job on permanent agentAgent busyJob running
3PermanentJob completesAgent readyJob complete
4CloudProvision new cloud agentAgent provisioningJob queued
5CloudCloud agent readyAgent readyJob queued
6CloudRun job on cloud agentAgent busyJob running
7CloudJob completesAgent readyJob complete
8CloudCloud agent cleanupAgent removedJob complete
💡 Job finishes on permanent agent or cloud agent; cloud agent is removed after job.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 5After Step 7Final
Agent StateNot assignedBusy (permanent)Ready (permanent)Ready (cloud)Ready (cloud)Removed (cloud)
Job StateNot startedRunningCompleteQueuedCompleteComplete
Key Moments - 2 Insights
Why does the cloud agent get removed after the job but the permanent agent stays?
Cloud agents are created dynamically for each job and removed after to save resources, as shown in steps 4 to 8 in the execution table. Permanent agents are always available and stay ready for new jobs.
What happens if the permanent agent is busy when a job starts?
The job waits in the queue until the permanent agent becomes ready, as indicated by the 'Agent ready' and 'Job queued' states in steps 1 and 2.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the cloud agent get provisioned?
AStep 2
BStep 6
CStep 4
DStep 8
💡 Hint
Check the 'Action' column for 'Provision new cloud agent' in the execution table.
According to the variable tracker, what is the agent state after step 7 for the cloud agent?
ARemoved
BReady
CBusy
DProvisioning
💡 Hint
Look at the 'Agent State' row under 'After Step 7' in the variable tracker.
If the permanent agent is busy, what happens to the job state at step 1?
AJob is queued
BJob runs immediately
CJob fails
DAgent is removed
💡 Hint
Refer to the 'Job State' column at step 1 in the execution table.
Concept Snapshot
Jenkins agents run jobs either on permanent or cloud nodes.
Permanent agents are always available.
Cloud agents are created and removed dynamically per job.
Jobs wait if agents are busy.
Cloud agents save resources by cleaning up after use.
Full Transcript
This visual execution shows how Jenkins handles two types of agents: permanent and cloud. When a job starts, Jenkins checks the agent type. For permanent agents, it uses an existing node that stays ready for jobs. For cloud agents, Jenkins provisions a new node, runs the job, then removes the node to save resources. The execution table traces each step, showing agent and job states. The variable tracker highlights how agent and job states change over time. Key moments clarify why cloud agents are removed and how jobs queue if agents are busy. The quiz tests understanding of provisioning steps, agent states, and job queuing behavior.

Practice

(1/5)
1. What is a key characteristic of a permanent agent in Jenkins?
easy
A. It runs only on cloud platforms like AWS or Azure.
B. It is always connected and ready to run jobs.
C. It starts only when a job is triggered and stops afterward.
D. It automatically scales based on job demand.

Solution

  1. Step 1: Understand permanent agent behavior

    Permanent agents are set up to be always online and ready to accept jobs without delay.
  2. Step 2: Compare with cloud agents

    Cloud agents start and stop dynamically, unlike permanent agents which stay connected.
  3. Final Answer:

    It is always connected and ready to run jobs. -> Option B
  4. Quick Check:

    Permanent agent = always connected [OK]
Hint: Permanent agents stay online; cloud agents start/stop [OK]
Common Mistakes:
  • Confusing permanent agents with cloud agents
  • Thinking permanent agents scale automatically
  • Assuming permanent agents only run on cloud
2. Which of the following is the correct way to define a cloud agent in Jenkins pipeline syntax?
easy
A. agent { permanent { name 'agent1' } }
B. agent { cloud { cloudName 'aws' } }
C. agent { docker { image 'cloud-agent' } }
D. agent { label 'cloud' }

Solution

  1. Step 1: Identify cloud agent syntax

    Jenkins pipeline uses agent { label 'cloud' } to target cloud agents provisioned with matching labels.
  2. Step 2: Eliminate other options

    agent { cloud { cloudName 'aws' } } is invalid syntax; C is for Docker agents, not cloud agents; D is incorrect syntax.
  3. Final Answer:

    agent { label 'cloud' } -> Option D
  4. Quick Check:

    Cloud agent syntax uses label { 'cloud' } [OK]
Hint: Cloud agents use agent { label 'cloud' } [OK]
Common Mistakes:
  • Using invalid 'cloud { cloudName }' syntax for cloud agents
  • Confusing Docker agent syntax with cloud agent
  • Trying to define permanent agents inside agent block
3. Given this Jenkinsfile snippet:
pipeline {
  agent { label 'cloud' }
  stages {
    stage('Build') {
      steps {
        echo 'Running on cloud agent'
      }
    }
  }
}

What will happen when this pipeline runs?
medium
A. It fails because 'cloud' label is invalid for agents.
B. It runs on a permanent agent labeled 'cloud'.
C. It runs on a cloud agent that starts and stops automatically.
D. It runs on the master node regardless of label.

Solution

  1. Step 1: Understand label usage

    The pipeline requests an agent with label 'cloud', which typically refers to a cloud agent.
  2. Step 2: Behavior of cloud agents

    Cloud agents start when needed and stop after the job finishes, matching the label usage.
  3. Final Answer:

    It runs on a cloud agent that starts and stops automatically. -> Option C
  4. Quick Check:

    Label 'cloud' triggers cloud agent start/stop [OK]
Hint: Label 'cloud' usually means dynamic cloud agent [OK]
Common Mistakes:
  • Assuming label 'cloud' means permanent agent
  • Thinking label usage causes failure
  • Assuming master node runs all jobs
4. You configured a cloud agent in Jenkins, but jobs never run on it and stay queued. What is the most likely cause?
medium
A. The cloud agent label is missing or mismatched in the job configuration.
B. The permanent agent is offline, so cloud agents cannot start.
C. The Jenkins master node is overloaded and blocking all agents.
D. The cloud agent plugin is not installed, causing syntax errors.

Solution

  1. Step 1: Check label matching

    Jobs must specify the correct label matching the cloud agent to run on it.
  2. Step 2: Understand job-agent assignment

    If labels don't match, Jenkins queues jobs waiting for suitable agents.
  3. Final Answer:

    The cloud agent label is missing or mismatched in the job configuration. -> Option A
  4. Quick Check:

    Label mismatch causes jobs to queue [OK]
Hint: Always match job label with agent label [OK]
Common Mistakes:
  • Assuming permanent agent status affects cloud agents
  • Blaming Jenkins master overload without evidence
  • Confusing plugin absence with job queuing
5. You want to optimize Jenkins to save resources by using cloud agents for most jobs but keep a permanent agent for critical builds. How should you configure labels and agents?
hard
A. Assign label 'critical' to the permanent agent and 'cloud' to cloud agents; assign jobs accordingly.
B. Use only permanent agents with label 'all' and avoid cloud agents to reduce complexity.
C. Assign all jobs to label 'cloud' and disable the permanent agent to save resources.
D. Configure cloud agents without labels and assign all jobs to the permanent agent.

Solution

  1. Step 1: Separate job types by labels

    Use distinct labels like 'critical' for permanent agent and 'cloud' for cloud agents to control job assignment.
  2. Step 2: Assign jobs to matching labels

    Critical builds use the permanent agent with 'critical' label; other jobs use cloud agents with 'cloud' label.
  3. Final Answer:

    Assign label 'critical' to the permanent agent and 'cloud' to cloud agents; assign jobs accordingly. -> Option A
  4. Quick Check:

    Use labels to separate permanent and cloud jobs [OK]
Hint: Label agents and jobs to control resource use [OK]
Common Mistakes:
  • Using only one label for all agents
  • Disabling permanent agent when critical builds exist
  • Not assigning labels to cloud agents
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