-
Notifications
You must be signed in to change notification settings - Fork 19
Setting up a Raspberry Pi as a Jenkins Agent
This guide will walk you through setting up a Raspberry Pi (or another Linux machine) as a Jenkins agent for Mbed CE
sudo apt-get install aptitude
sudo aptitude install gcc-arm-none-eabi gdb-multiarch cmake ninja-build openocd
sudo aptitude install libusb-1.0-0-dev libudev-dev # dependencies for USB tests
Note: Mbed needs at least CMake 3.19, if you don't have that version or a newer one in your package manager you will need to compile it from source instead.
From here: https://www.gdcorner.com/2019/12/27/JenkinsHomeLab-P2-LinuxAgents.html
sudo aptitude install default-jre
sudo adduser jenkins # and then follow the prompts, can set the password to "jenkins"
sudo usermod -G plugdev jenkins # Enable jenkins to access USB devices
sudo su jenkins
mkdir ~/.ssh
nano ~/.ssh/authorized_keys # paste the jenkins agent SSH public key into this file
You can now add the RPi in Jenkins via Manage Nodes and Clouds > New Node
- Remote Root Directory: /home/jenkins
- Labels:
<all Mbed targets connected to this node, separated by spaces>
- Launch Method: Launch via SSH
- Host:
<IP address of node>
- Credentials:
<use the Jenkins node key>
- Host Key Verification Strategy: Manually Trusted
After clicking OK on this screen, the node should be available for use!
- Set up udev rules and permissions per here
- Additionally, to enable USB tests to run, you will need to add extra udev rules:
# Mbed OS USB Device test suite
ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0007", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0205", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="0d28", ATTRS{idProduct}=="0206", MODE="660", GROUP="plugdev", TAG+="uaccess"
ATTRS{idVendor}=="1f00" ATTRS{idProduct}=="2013", ENV{ID_MM_DEVICE_IGNORE}="1", MODE="660", GROUP="plugdev"
ATTRS{idVendor}=="1f00" ATTRS{idProduct}=="2012", ENV{ID_MM_DEVICE_IGNORE}="1", MODE="660", GROUP="plugdev"
- Create a folder matching the Mbed target name and link the serial port in the location that the build job expects:
sudo mkdir -p /mbed/<target name>
sudo ln -s /dev/tty<target name> /mbed/<target name>/tty
The Mbed USB Mass Storage Device (MSD) test works by connecting a software-defined USB mass storage device and reading/writing files on it. In order for this test to work, we need to configure Linux to auto-mount the USB device in a location accessible to the jenkins user
Unfortunately, Raspberry Pi's file manager seems to always automount devices as the GUI user (your login), and there's no way to change this so jenkins
can access the devices too. So, we need to completely disable this automount functionality. You will need to start a GUI session (via X11 forwarding / VNC / physically being present), run the pcmanfm
executable, and uncheck both the "Mount xx automatically" checkboxes. See this SO answer for screenshots.
Now, we need to grant the jenkins user access to mount devices using udisksctl. Create the file /etc/polkit-1/localauthority/50-local.d/enable-mounting.pkla with the following content:
[Allow Plugdev users to Mount Disks]
Identity=unix-group:plugdev
Action=org.freedesktop.udisks2.*
ResultAny=yes
With this set up, the tests should be able to pass!