Mainframe Path Start learning free
Beginner7 min readLesson 2 of 5

Jenkins: controller, agents, jobs and plugins

Jenkins is a free, open-source automation server written in Java. The controller holds the configuration, schedules work and shows the results; agents are the machines that actually run the builds. Work is defined as jobs, most often Pipeline jobs, and almost every feature comes from a plugin.

The main parts

How a Jenkins installation is put together
Controller
The web interface and configurationQueues and schedules buildsStores build history, logs and credentialsShould run few or no builds itself
Agents
Machines that run the build stepsLinux, Windows, macOS, containers, and z/OS UNIXPicked by labels, such as linux or zosEach offers a number of executors (parallel slots)

Older documentation calls the controller the *master* and agents *slaves*. The Jenkins project replaced those names. You will still see them in old scripts and blog posts.

Jobs

Job typeWhen it is used
Freestyle projectSteps configured by clicking in the web interface. Fine for simple tasks, but hard to review and copy
PipelineSteps written as code in a Jenkinsfile and stored in Git. The normal choice today
Multibranch PipelineFinds every branch (and pull request) with a Jenkinsfile and builds each one automatically

What starts a build

Reading a build

Each run gets a build number (#57, #58…) and a result. Success means every step passed. Failure means a step failed, usually a command that exited with a non-zero status. Unstable usually means the build worked but some tests failed. Aborted means it was stopped. The Console Output page shows every command and its output, and the answer to 'why did it fail?' is almost always near the bottom.

The end of a failed build's console output
[Pipeline] sh
+ ./run-tests.sh
FAILED: OvertimeCalcTest.roundsToTwoDecimals
script returned exit code 1
[Pipeline] End of Pipeline
Finished: FAILURE

Plugins and credentials

Jenkins does very little on its own. Git integration, Pipeline support, test reports and links to other tools all come from plugins, and there are well over a thousand of them. Passwords, tokens and ssh keys are kept in Jenkins' credentials store and given to a build by ID, so they never appear in the Jenkinsfile and are masked in the console output.

TRY IT YOURSELF

In Jenkins, what is the name for the machine that actually runs the build steps, as opposed to the controller?

Show a hint

The controller hands the work to it.

Show the solution

An agent (also called a node).

Examples are for learning. Run commands and jobs only on a system you are authorised to use, such as a training or test system, and never on production without approval.

Common mistakes

Running builds on the controller

Builds there can slow down or endanger the server everyone depends on. Run them on agents.

Configuring everything by clicking

Freestyle settings are hard to review and easy to lose. Keep pipelines as code in a Jenkinsfile in Git.

Putting passwords in job settings or scripts

Use the credentials store and refer to the ID. Jenkins then hides the value in the logs.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← CI/CD in plain wordsPipelines as code: reading a Jenkinsfile →