how to install jenkins on raspberry pi

How to install Jenkins server on your Raspberry Pi?

What is Jenkins?

Introduction

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

 

Features

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

Video

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

Install Raspbian

The first thing you need is a working Raspbian installation
You can start with Raspbian 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 Raspbian installed on your Raspberry it’s fine, follow this installation guide with it
If not, you need to install Raspbian on it and you can follow this Raspbian 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
    ifconfig

When everything is correct, you can move to the next paragraph

Prerequisites: install java

Jenkins needs Java in order to run the server
So, you need to install Java JDK before everything else:

  • Install the Oracle Java SDK from the apt repository
    sudo apt install oracle-java8-jdk -y
  • After the installation, you can make sure that Java is correctly installed with:
    java -version
  • You should get something like this:
    java version "1.8.0_65"
    Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
    Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

Install Jenkins

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

Unlock Jenkins

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 configure it

  • 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:
    jenkins admin password
  • 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
    jenkins ready
  • Click on “Start using Jenkins” to access the main interface
    jenkins main page
  • 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

Jenkins configuration

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 Raspbian/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

Configuration files

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

Log files

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:

manage jenkins configuration

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

Jenkins usage

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

Got 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 by http at the URL beginning
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:

jenkins project menu

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
    backup jenkins

If you choose a local folder for the backups, don’t forget to copy them elsewhere for more security

Going further

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

Related questions

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 a lot of platforms. You can find all the information on this Docker page

Conclusion

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 🙂
Feel free to share your experience in the comments below

Leave a Comment