Building a Jenkins failure light using particle photon

  • January 9, 2018
  • 0
99xtechnology

Isuru Senadheera

Senior Technical Lead

We use Jenkins at our current project at 99X Technology as the continuous integration server. We also have a separate Jenkins instance running on a separate server, which executes periodical batch processing jobs against the production data.

When a Jenkins job fails, Jenkins would send an automated email to the development email group. In practice, those email notifications will easily stay in developers’ mailboxes without getting noticed. Sometimes, things remain failing for a big part of the day unnoticed, especially not-so-actively developed products and huge batch processing jobs in the system. So I wanted a way to communicate and let the team quickly recognize when something is not right.

A couple of years ago, one of my colleague built a similar Jenkins light. But it had a huge amount of electronic-related work to get it up and running. The integration with Jenkins server was done using a Jenkins notification application called Hudson tray application. We faced many integration issues there, which caused the Jenkins light to be unstable.

Solution

With IoT devices being so common these days, we found a handy little WiFi-enabled board (photon) from particle.io as a handy solution to wire into LEDs. One of the advantages of the particle is that it provides a free API that you can use to easily send a message to your photon without having to configure any infrastructure yourself. So all what we needed to do was to expose an API function from photon and to make an HTTP request from Jenkins to our api.particle.io endpoint with the desired state of the lights (green vs red).

Jenkins light using particle photon api

Getting started with the photon device was really easy. I just claimed my device through https://setup.particle.io/ and configured the WiFi settings, and the device was up-and-running within seconds!

I am no expert on developing electronic circuits. So I started with blink, a LED hello world app. Soon, I realized it was the ideal point to start building the Jenkins light. Particle’s web IDE https://build.particle.io/build is a handy dev environment and loading code into my photon device is super easy.

Photon blink an LED setup

We used two LEDs connected to different pins of the photon device to build the pilot Jenkins lights using the LEDs. I exposed a function from my device code to api.particle.io and then got the Jenkins post-build task plugin to send an HTTP request to particle API via a windows shell script. The shell script uses the CURL command line tool to check all the Jenkins jobs, if anything has failed.

Have a look at the particle code and windows script we used here: https://gist.github.com/isurusndr/88b4b5ae6367fe73464523894183abc1

Red and green LEDs plugged into photon board

Here is the final result with two LEDs plugged into the photon board as a pilot project. It is just USB powered and really easy to move around. We’ve been testing our pilot Jenkins lights for a few days now and I am really happy about how quickly we’ve been able to notice failures in Jenkins.

Since then, we improved our pilot Jenkins light, adding LED matrix panels for better visibility. We also extended it to have two set of lights on the same photon – one for Jenkins doing CI and the other for Jenkins handling batch processing of data.

 

For more great insights from Isuru, check out his writing on Medium 

Add comment

Your email address will not be published. Required fields are marked *