If you are a serious developer, you might be looking for tools to make your life easier and your applications more reliable. Jenkins is one solution you can use to build and test your software projects, and the good news is that it can be installed on Raspberry Pi.
Jenkins is an automation server which is not available in the Raspberry Pi OS repository. To install it, a new repository need to be added, it also required the Java JDK to works.
Don’t worry, I’ll show you step-by-step how to do this on your Raspberry Pi in this tutorial. I’ll start by an introduction and we’ll quickly move to the installation and configuration.
If you’re looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.
What is Jenkins?
Jenkins is an open-source automation server.
It helps developer teams in building, testing, deploying and automating any project.
You can enjoy the 1000+ available plugins to adapt Jenkins to your environment.
For example, you can integrate it with GitHub, LDAP or add email notifications.
The Jenkins project puts the following qualities forward on its home page:
- Continuous Integration and Continuous Delivery: You can tune your Jenkins server to a simple CI Server, or to integrate in real time any change the developer team made on the public hub
- Easy Installation: as you’ll see in the next paragraph, Jenkins is easy to install on any platform, and Raspberry Pi is perfect for this
- Easy Configuration: you can change everything from the web interface
- Plugins: like I already mentioned in the introduction, there are hundreds of plugins available to fit your needs
- Extensible: this goes along with the previous point, but you can easily improve Jenkins with all the available free plugins
To see Jenkins in action, you can check this demonstration video:
Jenkins’s installation guide
Now let’s dive into the Jenkins installation steps, it’s easy with all the commands below.
Here are the required steps to install Jenkins on Raspberry Pi:
- Install and update Raspberry Pi OS.
- Install Java.
- Add the Jenkins repository and install the corresponding package.
- Unlock the access to the web interface to configure it.
Install Raspberry Pi OS
The first thing you need is a working Raspberry Pi OS installation.
You can start with Raspberry Pi OS Lite, it’s OK because you don’t need a GUI for Jenkins, everything is available on the web interface.
If you already have any Raspberry Pi OS installed on your Raspberry, it’s fine, follow this installation guide with it.
If not, you need to install Raspberry Pi OS on it, and you can follow this Raspberry Pi OS installation guide if you need help to do this.
In any case, make sure you have:
- Internet working (ping google.com)
- Updated your system:
sudo apt update
sudo apt upgrade
- Enabled an SSH access:
sudo service ssh start
- Taken note of the Raspberry Pi IP Address
When everything is correct, you can move to the next paragraph.
Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips.
Prerequisites: install java
Jenkins needs Java to run the server.
So, you need to install Java JDK before everything else:
- Install the Java SDK from the apt repository
sudo apt install openjdk-11-jdk -y
- After the installation, you can make sure that Java is correctly installed with:
- You should get something like this:
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment (build 11.0.12+7-post-Raspbian-2deb10u1)
OpenJDK Server VM (build 11.0.12+7-post-Raspbian-2deb10u1, mixed mode)
If you experience any issue with this installation, I have an entire tutorial on how to install any Java version on Raspberry Pi.
Then, to install Jenkins on your Raspberry Pi, you need to add a new repository (to get the latest version):
- Download the repository key:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
- Add the new repository URL to your apt sources
sudo sh -c 'echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
- Update the apt cache
sudo apt update
- And finally install Jenkins
sudo apt install jenkins
This step will install Jenkins, create a Jenkins user to run the daemon, and create default configuration and log files.
This will also install the web interface we’ll enable in the next paragraph.
After the installation, Jenkins is immediately available on http://IP_ADDRESS:8080.
But on your first try, you’ll get an “error screen” indicating that Jenkins is locked:
This is a security measure to avoid anyone accessing the configuration interface before the administrator can configure it. Follow these steps to unlock the access:
- Display the content of the file in red on your Raspberry Pi:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- You’ll see a password, something like:
- Copy this password and paste in the field from the Jenkins page
- The following page I got is the “Offline” page.
It’s probably a bug on my side, but if needed you can configure a proxy to get an Internet access, or skip the plugins installation.
- If everything works fine, you should get a page that asks you to install basic plugins.
Install them and wait a few minutes for the installation to finish.
- Then move to the next page, to create your first administrator user.
- Fill the form with the credentials you want to use, and click next.
- Finally, the interface shows you the main URL and you can save and finish the configuration.
- Click on “Start using Jenkins” to access the main interface
- You can now use Jenkins like any other server.
That’s it, Jenkins is running on your Raspberry Pi, and you can start hosting your projects on it.
Remember that the Raspberry Pi storage is not unlimited, so for big projects it’s probably not a good idea to send everything on the Raspberry Pi. You should at least use an external USB drive to store your projects, even a cheap one (like this one on Amazon) will be way safer than your SD card.
In this section, I’ll give you some tips to configure and monitor your new Jenkins server.
Start and stop the Jenkins service
Jenkins is well integrated with Raspberry Pi OS/Debian, so it’s easy to manage the Jenkins service.
If something goes wrong, you can check the Jenkins service status, or start/stop it, if needed.
- Check the Jenkins service current status
sudo service jenkins status
- Start the service
sudo service jenkins start
- Stop the service
sudo service jenkins stop
Generally, you can do everything from the web interface, so most of the time you don’t need to edit the configuration files.
If for some reason you want to check them, Jenkins stores all files in the /var/lib/jenkins folder.
Jenkins also uses the default /var/log folder to save logs files.
You can check the /var/log/jenkins/ directory for the latest logs.
But you can also read them from the web interface.
Other configuration tasks
For anything else, you can check the “Manage Jenkins” entry in the main menu.
You’ll get something like this:
From there, you can edit everything you want to adapt your configuration to your specific needs.
You can also manage your users from this menu.
Finally, I’ll give you here some basic advice to start with Jenkins if you are new with this software.
Install new plugins
The first thing to consider is to install new plugins, especially if you got the “Offline page” during the installation.
Go to Manage Jenkins > Manage plugins.
In my case, I had this error on the page:
There were errors checking the update sites: SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
If you have the same thing, you can go to the “Advanced” tab.
Then in the “Update Site” field, replace https with http in the URL.
Click on Submit, it should be OK now (if not, click “Check updates” on the “Manage plugins” home page).
Finally, go to the “Available” tab and look for the plugins you need to install.
You can use the search engine on the top to filter the list.
You can also check for plugins on the official website, I find it more convenient.
Create a basic project
Now, let’s say you want to create a new project on Jenkins:
- The first thing to do is to go back to the home page and click “Create new jobs”.
- Enter a project name and select the project type corresponding to your code.
If you installed some plugins, you will probably get the choice between projects type (GitHub, Subversion, …)
If not, start with the “Freestyle Project”.
- On the next page, you’ll get the project details that you can fill with your information.
You can for example select the source code management tool (Git or Subversion if installed).
You can also choose triggers to automatically launch a build.
- When everything is fine, click on Save to access the workspace.
You can always go back to the previous configuration form with the “Configure” menu in the left menu.
You can now manage everything with the left menu in your project:
Backup your project
Even if you can try to back up the Jenkins folder to keep your projects safe, the best option is to install a backup plugin:
- Go to Manage Jenkins > Manage plugins.
- In the available tab, look for “Backup Plugin”.
- Install it.
- After the installation, you’ll get a new link in Manage Jenkins : “Backup Manager”.
- Click on “Setup” and configure it as you want.
If you choose a local folder for the backups, don’t forget to copy them elsewhere for more security.
As everything after your project creation highly depends on what kind of project you want to host on Jenkins, I’ll let you check the official documentation for specific questions.
You can also use different tools to discuss with Jenkins users.
You have everything you need on this page, to find the way you prefer to communicate with them.
Is it possible to move Jenkins to another server (hardware) if my Raspberry Pi is full? Yes, you can use the Backup Manager tool I showed you previously to create a full backup, and import it on another server. So, you can try Jenkins on Raspberry Pi and move to something more powerful in a second step.
Is there a way to use Jenkins in a Docker container? Yes, absolutely. It’s even the recommended method for many platforms. You can find all the information on this Docker page.
If you are looking for exclusive tutorials, I post a new course each month, available for premium members only. Join the community to get access to all of them right now!
And that’s it! You know now everything you need to install and configure Jenkins for your Raspberry Pi.
The installation is straightforward, but the usage can be a little tricky at the beginning if you never used Jenkins before.
I’m sure you’ll quickly find what to do with Jenkins on your Raspberry Pi 🙂
Whenever you’re ready, here are other ways I can help you:
The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.
You can also find all my recommendations for tools and hardware on this page.