0
0
Jenkinsdevops~10 mins

Master-agent architecture in Jenkins - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Master-agent architecture
Master Node
Assign Job
Agent Node
Execute Job
Send Results
Master Node Receives Results
The Jenkins master assigns jobs to agents, which run the jobs and send results back to the master.
Execution Sample
Jenkins
master.launchJob(job1)
agent1.execute(job1)
agent1.sendResult(master)
master.receiveResult(job1)
Master sends a job to agent, agent runs it, then sends back results to master.
Process Table
StepActionNodeJob StateResult SentMaster State
1Master assigns job1Masterjob1 assignedNoWaiting for result
2Agent1 starts job1Agent1job1 runningNoWaiting for result
3Agent1 completes job1Agent1job1 doneYesWaiting for result
4Agent1 sends resultAgent1job1 doneYesResult sent
5Master receives resultMasterjob1 doneYesResult received
6Master updates job statusMasterjob1 completeYesJob complete
💡 Job1 completed and result received by master, execution ends.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 5Final
job1_statenot assignedassignedrunningdonedonecomplete
result_sentNoNoNoYesYesYes
master_stateidlewaiting for resultwaiting for resultwaiting for resultresult receivedjob complete
Key Moments - 3 Insights
Why does the master wait after assigning the job?
Because the master waits for the agent to finish and send back the job result, as shown in steps 1 to 5 in the execution table.
Can the agent run the job without the master assigning it first?
No, the master must assign the job first (step 1) before the agent can start running it (step 2).
What happens if the agent does not send the result back?
The master remains in 'waiting for result' state and does not mark the job complete, as seen in the master_state variable in the tracker.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the agent start running the job?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Check the 'Action' and 'Node' columns for when the agent starts the job.
According to the variable tracker, what is the job1_state after step 3?
Aassigned
Brunning
Cdone
Dcomplete
💡 Hint
Look at the 'job1_state' row under 'After Step 3' in the variable tracker.
If the agent never sends the result, what will the master's state be after step 5?
Awaiting for result
Bresult received
Cjob complete
Didle
💡 Hint
Refer to the 'master_state' variable in the tracker and the explanation in key moments.
Concept Snapshot
Jenkins Master-Agent Architecture:
- Master assigns jobs to agents.
- Agents run jobs and send results back.
- Master waits for results before marking jobs complete.
- Agents cannot run jobs without master assignment.
- Communication ensures distributed job execution.
Full Transcript
In Jenkins master-agent architecture, the master node assigns jobs to agent nodes. The agents execute the assigned jobs and send the results back to the master. The master waits for these results before marking the job as complete. This flow ensures that jobs are distributed and managed efficiently. The master controls job assignment and collects results, while agents handle the execution workload.