Agentic AI with Java: Live Cohort
JenkinsSecurity & Distributed Builds

Jenkins Master Agent Architecture Introduction

Understand why running every build on the Jenkins server becomes a problem, how the controller and agent architecture (formerly master and slave) spreads the work, and the vocabulary behind it.

Up to now, everything has happened on one machine. We created a Linux server, installed Jenkins on it, and every job we ran (the shell job, the Maven build, the parameterized job) created its workspace on that same server. Open any console output and you see it: Building in workspace /var/lib/jenkins/workspace/..., on the Jenkins machine itself.

With three small jobs, that is fine. With thirty jobs, several pipelines and Docker image builds, it is not.

Problems with a single node

ProblemWhat you notice
Slow buildsBuilds compete for the same few CPUs
High CPU usageThe Jenkins web UI becomes sluggish or stops responding during builds
Memory issuesMaven, Gradle and Docker all want memory. The Linux OOM killer may kill a build, or Jenkins itself
Long build queueOnly two executors, so builds wait in the queue
One operating systemYou cannot build a Windows or macOS application on a Linux-only Jenkins
SecurityBuilds on the Jenkins server can read Jenkins' own files, including stored credentials

That last point is why Jenkins shows the warning "Building on the built-in node can be a security issue" on the Manage Jenkins page.

The idea: one coordinator, many workers

Keep Jenkins on its current server, but stop running builds there. Instead, connect other machines, and send the builds to them.

Jenkins controller receives users and GitHub webhooks and sends builds to Linux, Docker and Windows agents over SSH or inbound connections
  • The machine where Jenkins is installed becomes the controller. It serves the web UI, stores job configuration, plugins and credentials, keeps the build queue, decides which build runs where, and stores logs and results.
  • The other machines are agents. They run the actual build steps: clone the code, run Maven, build Docker images. The workspace and the generated WAR file live on the agent.

Agents do not need to match the controller. The controller can be Ubuntu, while one agent is Linux, another is Windows, and another is a Mac for iOS builds.

"Master" and "slave" are the old names

The video and the lecture title use master and slave, and you will still find these words in older blogs, Stack Overflow answers and plugin names (the SSH agents plugin was called "SSH Slaves" until version 1.31.0). The Jenkins project replaced them years ago:

Old termCurrent Jenkins term
MasterController
SlaveAgent
Master node (the node inside the controller)Built-in node
SSH Slaves pluginSSH Build Agents plugin

The ideas are exactly the same. In these notes we use controller and agent, because that is what the current Jenkins UI and documentation show. For example, the launch method on the agent page is called "Launch agent by connecting it to the controller".

Benefits

BenefitWhy
Faster buildsEach agent brings its own CPU and memory
Parallel executionEvery agent adds executors, so more builds run at the same time
Better resource useThe controller stays light. Heavy agents can be stopped when idle
ScalabilityNeed more capacity? Add another agent. No need to touch the controller
Multiple operating systemsBuild Linux, Windows and macOS software from one Jenkins
Isolation and securityBuilds cannot read the controller's files and secrets

Vocabulary you need for the next lesson

TermMeaning
NodeAny machine that can run builds. The controller's built-in node and every agent are nodes
ExecutorA slot for one build at a time on a node. Two executors means two builds in parallel on that node
LabelA tag on an agent, such as linux, maven or docker. Jobs ask for a label, and Jenkins picks any agent that has it
Remote root directoryThe folder on the agent where Jenkins keeps its files and the job workspaces
Launch methodHow the agent connects. Either the controller starts it over SSH, or the agent connects to the controller itself (inbound)
Permanent agentA machine you add and manage yourself. The opposite is a cloud agent, created on demand (EC2, Docker, Kubernetes) and removed afterwards

How agents connect

MethodHow it worksWhen to use
Launch agents via SSHThe controller SSHes into the agent, copies remoting.jar and starts it with JavaLinux agents the controller can reach. This is what we do next
Launch agent by connecting it to the controller (inbound)You run a small Java command on the agent and it connects out to the controllerAgents behind a firewall, Windows machines
Cloud agents (plugins)Jenkins creates a VM or container per build and deletes it afterLarge or spiky workloads, Kubernetes

Whichever method you use, the agent runs a small Java process, so every agent needs Java installed, a version the controller supports (Java 21 for current Jenkins).

In production, the controller does not build

The usual recommendation is to set the built-in node to 0 executors once agents exist, so that no build ever runs on the controller. In this course we keep it simple and still run some demos on the built-in node to save money, but the real-world pattern is agents only.

Next, we create an agent, connect it over SSH, and move the Maven build onto it: Configure a Jenkins Agent Using SSH & Run Jobs on an Agent.

Try It Yourself

  1. Open the console output of any build you have run and find the workspace path. Confirm it is on the Jenkins server.
  2. Open Manage Jenkins > Nodes. How many nodes and executors do you have right now?
  3. On the Jenkins server, run du -sh /var/lib/jenkins/workspace /var/lib/jenkins/.m2 to see how much disk the builds already use.
  4. Explain to a colleague, in two sentences, what the controller does and what an agent does.

Official references


Written By: Shramik Masti

How is this guide?

Last updated on