Install and configure the Jenkins build server

Install and Configure Jenkins


Duration: 1:00

Jenkins is an open source automation server. It’s often used in Continuous Integration, which means it automatically creates and tests builds when developers commit code to a repository.

Jenkins requires a JVM to run. It runs off of one master server, which manages many agents (build machines.) For example, if we are building a Unity game for Windows, Linux, macOS, and iOS, our Jenkins server might run on a permanent Ubuntu server, with Linux, Windows, and macOS agents used as needed to build the various targets.

Jenkins is not just the server and agents, though. Jenkins integrates with many tools via a large collection of independently-updated plugins. These plugins allow Jenkins to fetch source code, run different build tools, test frameworks, and more. They also require administration and management.

Other CI choices fall into three categories: servers like Jenkins, which you host yourself; SaaS offerings like CircleCI or GitHub Actions; or Cloud services like AWS CodePipeline or Google Cloud Build.

In this tutorial, we’ll look at different ways to install Jenkins on Ubuntu so you can start setting up builds and pipelines.

What you’ll learn

  • How to install Jenkins via snap
  • How to install Jenkins and dependencies via a PPA
  • How to unlock Jenkins and create an admin user

What you’ll need

Choosing your Jenkins version

Duration 1:00

Our first decision is which version of Jenkins to use.
Jenkins releases in two lines: a weekly release and a LTS release.

For production use, an LTS release will be better tested and reliable, while also receiving security updates.

But if you have a specific feature or compatible tool you want to explore, you may want to try the bleeding edge.

If in doubt, stick to the LTS release. Infrastructure should be reliable above all!

Option 1: Install Jenkins using Snap

Duration 3:00

Using a snap takes care of all our dependencies and the Java Runtime.

If we want to stick with a tested and reliable version of Jenkins, run this at the command line:

sudo snap install jenkins --classic

If we want to track the weekly releases, use the “–edge” option:

sudo snap install jenkins --edge --classic

We can verify our installation by checking snap’s logs:

sudo snap logs jenkins

There’s one gotcha to using Snap for Jenkins. The snap “stable” release often lags behind the Jenkins LTS release. So double-check what version you are working with.

Option 2: Add the third-party package repository

Duration 5:00

Jenkins updates their own package repositories, so if we want to track releases directly from the developers, we can add them to our sources list.

This means that when we run apt update and apt upgrade, we won’t just be installing software from Ubuntu. Our system will also check the packages Jenkins provides. Allowing third-party software can be a security concern, but official developer repositories are safer than most.

Install Java Runtime prerequisite

Due to differences between the Oracle JRE and OpenJDK JRE, it’s our responsibility to provide a Java Runtime for the packaged version of Jenkins. (The snap takes care of all this automatically). If you don’t already have one installed (try ‘java -version’ to see), use the default:

sudo apt install default-jre-headless

Jenkins is tested with the OpenJDK JRE 8 and JRE 11. Newer versions of the JVM are not supported at this time.

Adding the LTS Jenkins apt repository

First, we’ll add the developer PGP key to your system. This lets the package manager verify that the .deb packages it fetches are signed by the developer.

wget -q -O - | sudo apt-key add -

Next, we’ll add a Jenkins entry to our list of apt sources:

sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

These two steps make the Jenkins LTS Debian/Ubuntu packages available to apt. Now, we can run:

sudo apt update
sudo apt install jenkins

Note that we’ll get an error if we forget to install the JRE first.

Adding the weekly Jenkins apt repository

If we want to run our build server on the very latest Jenkins releases, the commands are almost the same. We just replace “debian-stable” with “debian”:

wget -q -O - | sudo apt-key add -
sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

Then continue to install as usual. (Note that we can’t have both the LTS and the weekly repos at the same time.)

Unlock Jenkins

Duration 3:00

By default, Jenkins runs on port 8080. So we can point our web browser at our server and enter the Jenkins administrator password.

(Need to find out your server’s IP address? Try hostname -I)

For example, your Jenkins server will be at something like Your browser may automatically try a secure connection with https, but that won’t work without additional setup.

Finding the password

Under “Getting Started”, Jenkins should now be prompting you for the administrator password.

Head back to the server command line and run this if using the snap:


(with the number changed to match what Jenkins says in the browser)

Or this command if using the Jenkins package repository:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Install plugins and create personal admin user

Duration 3:00

Picking your plugins

There are literally hundreds Jenkins plugins, so you can customize Jenkins to fit your needs.

After unlocking Jenkins, you’ll have the option either to pick only the plugins you know you need, or go for the standard batch. Maybe you don’t use Git, but do use Perforce. Maybe you plan to use dotnet agents, but no JVM builder like Ant and Maven.

There’s no performance or large storage penalties to having unused plugins installed, though, so don’t worry too much. You can always change them later.

Create an admin user

Jenkins will give you the option of creating a new admin user. This is a good idea, but you can also go on using the original admin user. Make sure to change that account’s password, though.

That’s all!

Duration 1:00

You now have a functioning installation of Jenkins and can start automating build and creating pipelines!

Next Steps

I’d like to walk back some of the exuberance regarding plugins and performance. And I’d like to add a bit about using ‘apt mark’ to freeze the Jenkins PPA version, if tight update control is desired.

This is my first try at a tutorial, so I’d love to hear any feedback!

Hi, how about use docker to install Jenkins? it’s easier I think, thank you. :upside_down_face: