Continuous Integration for C/C++ on Raspberry Pi: Part2 – Jenkins

In the Part 1 of the series we sat up the Dockerized cross-compile tool-chain. In this Part we continue our journey setting up Jenkins.

Jenkins is an open source automation server which is the heart of a CI/CD process. Using Jenkins we set up a pipeline which Builds our sample code, transfer it to Raspberry Pi (Deploy) and finally run it (Test).

Step 1 – Installing Java

Jenkins is based on Java. So we need to install Java on our Virtual machine which we prepared in Part 1.

sudo apt-get update -y
sudo apt-get -y install openjdk-11-jdk

Step 2 – Installing Jenkins

Run the following commands one by one to install Jenkins.

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

Step 3 – Configure Jenkins

For the first run you need initial admin password. Run the following command to find it out and copy it, we need it later.

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

We need to add Jenkins user to Sudoer so it can run Docker commands (thanks to this)

sudo su
visudo -f /etc/sudoers

Add following to the end of file:


Moreover, Jenkins’ user must be able to SSH to the Raspberry Pi, We first define a password for “jenkins” user:

sudo passwd jenkins
su jenkins

Then thanks to this post we set up SSH key for Jenkins. After adding the SSH key to the Raspberry Pi we should manually run and test SSH once:

jenkins@us01:~$ ssh pi@ ls -l
total 24
drwxr-xr-x 3 pi pi 4096 Feb 13 12:06 deploy
-rwxr-xr-x 1 pi pi 11408 Feb 13 17:43 hello_arm

Now everything should be ready for the Jenkins to patch thing up!

Step 4 – Jenkins Pipeline

First we configure the Jenkins web interface using the password from previous step. It is very straight forward: Install suggested plugins, Create First Admin User then install blue Ocean plugin for the sake of simplicity.

I have prepared a Jenkins pipeline for the simple “Hello World” Project of Part 1. As you can see it has 3 stages: stage 1 builds the code, stage 2 deploy it by transferring it to the Raspberry Pi and finally at stage 3 we run the binary to test it.

You can clone or fork the project from this Github repo:

git clone

Then you need to configure the pipeline in Jenkins:

You need to give the access token from Github to to Jenkins. This Youtube Video is very helpful regarding this part.

If you sat up everything as said in this tutorial you should get green check mark for all three stages. To complete the loop of continuous integration, after each commit on git, system should automatically start the pipeline. This is possible by using Webhooks. In the next part we would set up our Git server locally so we can notify Jenkins on Git commits using Webhooks.

آیا این مطلب مفید بود؟


I am Hamed, An embedded system developer and SBC enthusiast. Here I share projects and news related to single board computers, SBCs or as I call Funputers. If you have any comments, questions, notes etc... please do not hesitate to let me know via contact form or comments sections :)

Add comment