Bird
Raised Fist0
Jenkinsdevops~20 mins

Master-agent architecture in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Master-Agent Architecture Expert
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Jenkins Master-Agent Communication

In Jenkins master-agent architecture, what is the primary role of the agent?

AExecute build jobs assigned by the master
BManage user authentication and authorization
CStore build artifacts centrally
DSchedule build jobs on the master node
Attempts:
2 left
💡 Hint

Think about which component actually runs the build tasks.

💻 Command Output
intermediate
2:00remaining
Agent Connection Status Command Output

What is the output of the following Jenkins CLI command when the agent is connected and online?

java -jar jenkins-cli.jar -s http://jenkins.example.com list-agents
AError: Command not found
B
agent1  Online  Building
agent2  Online  Idle
C
agent1  Online  Idle
agent2  Offline  Disconnected
D
agent1  Offline  Disconnected
agent2  Offline  Disconnected
Attempts:
2 left
💡 Hint

Look for the status that indicates the agent is connected and ready.

❓ Configuration
advanced
2:30remaining
Configuring Agent Launch Method

Which configuration snippet correctly sets a Jenkins agent to launch via SSH with the hostname 'agent-host' and user 'jenkins-user'?

A
<slave>
  <name>agent1</name>
  <launcher class="hudson.plugins.sshslaves.SSHLauncher">
    <host>agent-host</host>
    <port>22</port>
    <credentialsId>jenkins-user</credentialsId>
  </launcher>
</slave>
B
<slave>
  <name>agent1</name>
  <launcher class="hudson.slaves.JNLPLauncher"/>
  <host>agent-host</host>
  <user>jenkins-user</user>
</slave>
C
<agent>
  <name>agent1</name>
  <launchMethod>SSH</launchMethod>
  <host>agent-host</host>
  <user>jenkins-user</user>
</agent>
D
<slave>
  <name>agent1</name>
  <launcher class="hudson.plugins.sshslaves.SSHLauncher">
    <hostname>agent-host</hostname>
    <port>22</port>
    <user>jenkins-user</user>
  </launcher>
</slave>
Attempts:
2 left
💡 Hint

Check the XML tags and attribute names for SSHLauncher configuration.

❓ Troubleshoot
advanced
2:00remaining
Agent Connection Failure Diagnosis

A Jenkins agent fails to connect to the master and shows 'Disconnected' status. Which of the following is the most likely cause?

AThe Jenkins master URL is set to HTTP instead of HTTPS
BThe master node is running out of disk space
CThe agent has too many executors configured
DThe agent's JNLP secret key is incorrect or missing
Attempts:
2 left
💡 Hint

Consider what is required for secure agent authentication.

🔀 Workflow
expert
3:00remaining
Master-Agent Job Execution Flow

Arrange the following steps in the correct order for a Jenkins job executed on an agent:

A2,1,3,4
B1,2,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint

Think about the logical flow from scheduling to execution to reporting.

Practice

(1/5)
1. What is the main role of the Jenkins master in the master-agent architecture?
easy
A. To run jobs on different machines
B. To control and schedule jobs
C. To store job logs only
D. To act as a backup server

Solution

  1. Step 1: Understand the master role

    The Jenkins master is responsible for controlling and scheduling jobs, meaning it decides when and where jobs run.
  2. Step 2: Differentiate from agent role

    Agents actually run the jobs on separate machines, not the master.
  3. Final Answer:

    To control and schedule jobs -> Option B
  4. Quick Check:

    Master controls jobs = B [OK]
Hint: Master schedules jobs; agents run them [OK]
Common Mistakes:
  • Confusing master with agent role
  • Thinking master runs jobs directly
  • Assuming master only stores logs
2. Which of the following is the correct way to define an agent in a Jenkins pipeline script?
easy
A. run agent
B. master agent
C. agent any
D. node master

Solution

  1. Step 1: Recall Jenkins pipeline syntax

    In Jenkins declarative pipeline, agent any means the job can run on any available agent.
  2. Step 2: Check other options

    Options like master agent, run agent, and node master are not valid syntax for defining agents.
  3. Final Answer:

    agent any -> Option C
  4. Quick Check:

    Correct agent syntax = A [OK]
Hint: Use 'agent any' to run on any available agent [OK]
Common Mistakes:
  • Using invalid keywords like 'master agent'
  • Confusing 'node' with 'agent'
  • Writing 'run agent' which is not valid
3. Given this Jenkins pipeline snippet, what will happen?
pipeline {
  agent { label 'linux' }
  stages {
    stage('Build') {
      steps {
        echo 'Building on Linux agent'
      }
    }
  }
}
medium
A. The job runs on any available agent
B. The job runs on the master node
C. The job fails due to syntax error
D. The job runs on an agent labeled 'linux'

Solution

  1. Step 1: Analyze the agent label

    The pipeline specifies agent { label 'linux' }, so it will run on an agent with the label 'linux'.
  2. Step 2: Understand job execution

    Since the label is specific, the job will not run on any agent or the master unless they have that label.
  3. Final Answer:

    The job runs on an agent labeled 'linux' -> Option D
  4. Quick Check:

    Agent label 'linux' = C [OK]
Hint: Agent label selects specific machine for job [OK]
Common Mistakes:
  • Assuming 'agent any' runs here
  • Thinking job runs on master by default
  • Believing syntax causes failure
4. You configured an agent but Jenkins shows it as offline. What is the most likely cause?
medium
A. Agent machine is turned off or unreachable
B. Master node is overloaded
C. Pipeline syntax error in Jenkinsfile
D. Agent label does not match any job

Solution

  1. Step 1: Understand agent offline status

    An agent shows offline if Jenkins cannot connect to it, often because the machine is off or network unreachable.
  2. Step 2: Eliminate other causes

    Master overload or pipeline syntax errors do not cause agent offline status. Label mismatch prevents job assignment but does not make agent offline.
  3. Final Answer:

    Agent machine is turned off or unreachable -> Option A
  4. Quick Check:

    Offline agent = unreachable machine [OK]
Hint: Offline agent means machine unreachable or off [OK]
Common Mistakes:
  • Blaming master overload for offline agent
  • Confusing syntax errors with connectivity
  • Thinking label mismatch causes offline
5. How can you improve Jenkins performance when running many jobs simultaneously using master-agent architecture?
hard
A. Add more agents to distribute the workload
B. Run all jobs on the master node to avoid delays
C. Disable agents to reduce network traffic
D. Use only one agent with high CPU

Solution

  1. Step 1: Understand workload distribution

    Adding more agents allows Jenkins to run jobs in parallel on different machines, improving performance.
  2. Step 2: Evaluate other options

    Running all jobs on master overloads it, disabling agents reduces capacity, and one agent limits parallelism.
  3. Final Answer:

    Add more agents to distribute the workload -> Option A
  4. Quick Check:

    More agents = better parallel job handling [OK]
Hint: More agents mean faster job execution [OK]
Common Mistakes:
  • Overloading master with all jobs
  • Disabling agents thinking it helps
  • Relying on single powerful agent only
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