Jenkins can use slave nodes on Raspberry Pi for remote compilation of ARM projects.
It can be rather tricky and difficult to setup and configure toolchains for ARM cross compilation. Why not use a real ARM device for compiling the code and use the generated binaries (remote compilation)?
In our example, there is already a Jenkins build server (master) installed and running on some server reachable via Internet. In order to use Raspberry Pis for remote compilation we have to solve these problems:
- Utilize the Raspberry Pi as slave nodes so that Jenkins can perform its remote compilation on it
- The Raspberry Pi is a local device behind some kind of router, firewall, etc. with neither public nor static IP. So Jenkins master won’t be able to connect to it.
- Physical devices can be offline due to damage, technical problems, etc. We have to find a way for redundancy
Jenkins Slave Nodes
Jenkins can perform its builds in a distributed way by utilizing so called slave nodes – small software agents turning their host system into additional Jenkins build resources.
To turn a Raspberry Pi into a Jenkins slave node, slave.jar must be running on the target platform. Jenkins master can then delegate builds to this slave.
The hidden Pi
In our example scenario Jenkins master runs on a public internet server (e.g. as a cloud service) while the Raspberry Pi is located in some office – behind a router. So the IP address of the build slave node is neither static nor public. How can Jenkins master establish a connection to its node? It can’t.
The solution is inversion of control: the slave node establishes a connection to Jenkins master, which can be realized using the Java Web Start approach via JNLP.
This must be done going the headless way – without GUI, as described in the documentation.
The slave node software shall be started each time the Raspberry Pi is booting, so that Jenkins master can utilize this slave. One possibility is to add the slave launch command to file /etc/rc.local – for example:
java -jar slave.jar -jnlpCredentials <user>:<password> -jnlpUrl http://jenkins.mydomain.com:8080/computer/raspi1/slave-agent.jnlp
This connection however won’t last forever. The DSL provider for example may decide to assign a new IP address every day at 1:34 am (in my case!). A simple cronjob rebooting the Raspberry Pi at 02:00 am solves the problem.
Providing Redundant Slave Nodes
Technical problem, such as damage or interrupted internet connections may prevent Jenkins slave nodes from getting online.
Best practice in order to grant acceptable availability is to provide several, locally distributed slave platforms.