Jenkins Job Traffic Lights

by zolv in Circuits > LEDs

2528 Views, 17 Favorites, 0 Comments

Jenkins Job Traffic Lights

lights.jpg

In software engineering, continuous integrationis the practice of merging all developer working copies to a shared mainline several times a day. Some of the best practices to achieve that are:

  • everyone commits to the baseline every day,
  • automate the build,
  • everyone can see the results of the latest builds.
  • ...and many others.

To fulfill just these 3 points above, it is important to be notified about build status as fast as possible.

This project helps to achieve that by creating a mini, personal traffic lights which indicates current build status. I've built 2 sets of traffic lights which are integrated to Jenkins automation server which is pulled by NodeMCU periodically via WiFi.

Materials and Tools

Materials I used:

  • NodeMCU (I used v3) (BangGood.com)
  • Male to Female breadboard jumper cables, (BangGood.com)
  • 2 sets of LEDs: red, yellow, green (BangGood.com)
  • 2 sets of 3 resistors (450Ω, 500Ω, 22Ω)
  • 2 thin but long prototype PCB boards (BangGood.com)
  • microUSB cable as a power supply
  • Some box (I used one for electric high voltage components. I found many different shapes and cheap in my local DIY retailer store)
  • 2 pens or 2 thick pipes 0.5-1cm internal diameter; and/or 2 thick drink straws

Tools needed:

  • Sharp knife (e.g. utility knife for cutting carpet)
  • Rotary tool
  • Hot glue gun
  • Soldering station
  • Pliers, diagonal pliers/side cutters
  • Screwdriver
  • Piece of thick paper
  • Double-sided adhesive tape
  • You

Traffic Lights

IMG_20170708_234741.jpg
IMG_20170708_234811.jpg
IMG_20170709_001051.jpg
IMG_20170709_002324.jpg
IMG_20170709_002557.jpg
IMG_20170709_002934.jpg
IMG_20170710_003528.jpg
IMG_20170710_003616.jpg

To build traffic lights, we use prototyping board 20x80mm. Solder LEDs so they are positioned in a line. I've used these resistor values:

  • red: 510Ω
  • yellow: 470Ω
  • green: 22Ω

Values are much higher than recommended (20mA max current per LED), but experimenting with different values, the light is not too bright and also all 3 have similar intensity. Please note that voltage is 3.3V for NodeMCU.

Wiring is straight forward, just connect (solder) cathode of each LED with resistor and then solder to male ending of jumper cable. On one side of the board I wanted only LED elements without any other "popping up" parts like resistor legs, wires and so on. That's why I've used a "technique" which is a kind of SMD using PCB components.

We leave it like this for now; the lights cover will be done later.

Box - Main

IMG_20170712_224217.jpg
IMG_20170712_224322.jpg
IMG_20170712_224305.jpg
IMG_20170712_225348.jpg
IMG_20170712_225131.jpg
IMG_20170712_224352.jpg

We need to embed our NodeMCU to the bottom of the box. The box needs a hole for microUSB port so we can power up the main unit. I measured raughly the hole position and I just drilled it.

Then I attached the plastic spacers using screws to nodemcu. I put some glue in each corner of the box and I put the whole construction onto it. After it cooled down, I unscrewed NodeMCU and put some additional hot glue around the spacers which I was sure were positioned perfectly for NodeMCU. Thanx to this, nothing is wobbling inside the box and we can easily attach the microUSB port without moving stuff inside.

Box - Lid

IMG_20170716_211311.jpg
IMG_20170716_212359.jpg
IMG_20170717_212524.jpg
IMG_20170717_212723.jpg
IMG_20170717_211230.jpg
IMG_20170712_231956.jpg
IMG_20170717_214332.jpg

First I tried to use a drink straws as a pole for my traffic lights but after some testing, I found out that the plastic is too thin and when I wanted to use a hot glue to attach it, it just got very soft and even changed its shape. So I decided to use something harder - pens. I've chosen some cheap transparent pens, which I cut off in desired length and put 4 cables (1 at a time) from traffic lights through the pipe.

I drilled holes in a middle line of the lid according to the pen's diameter. Then I embedded pens inside holes and I hotglued them on the bottom side of the lid trying to keep the poles straight.

I put also some hot glue on top of the pole to attach the traffic lights boards to the poles.

Assembling

IMG_20170717_221436.jpg
IMG_20170717_215654.jpg

I connected wires to the NodeMCU (pinout):

Left traffic light:

  • red to D2 (GPIO4)
  • yellow to D3 (GPIO0)
  • green to D4 (GPIO2)
  • ground to GND (I just chose one of GND pin of NodeMCU)

RIght traffic light:

  • red to D5 (GPIO14)
  • yellow to D6 (GPIO12)
  • green to D7 (GPIO13)
  • ground to GND (Ijust chose one of GND pin of NodeMCU)

...and I closed the lid. The wires I chose were quite long so I had a little problems with putting them all inside the small box, but somehow I managed to do it.

Lights' Cover

IMG_20170720_024534.jpg
IMG_20170720_025007.jpg
IMG_20170720_025840.jpg
IMG_20170720_025757.jpg
IMG_20170720_030414.jpg
IMG_20170720_030751.jpg
IMG_20170720_030838.jpg
IMG_20170720_030853.jpg
IMG_20170720_031319.jpg
IMG_20170720_031335.jpg

I couldn't find any ready solutions as a lights' covers - some kind of boxes from candies or so. So I decided to build them by hand just by cutting a box from a paper.

The size of the box I chose was: 20mm x 15mm x 85mm.

I cut the holes so that I cut a kind of "stars" in proper places where the LEDs were positioned. I glued them using double sided adhesive tape.

To cover the transparent poles, You can use some permanent marker, nontransparent scotch tape,... I used black drink straws which I cut through from end to end. Then I covered the poles.

I was more than happy of final result.

Software

There are many approaches to indicate the current build state. I implemented such a behavior:

Red or green light lights up when the build is failing or passing accordingly. Yellow light blinks every time there is made an HTTP call and is continously switched on when a plan is currently building.

You can easily change the implementation according to Your needs - try to experiment and check what fits You and/or Your team.

You need to setup the code before uploading it to Your NodeMCU. You need to set max 2 WiFis.

Also You need to set Your user token. To get API token, click on Your user name on top-right in Jenkins, then Configuration. You can find a button "Show API token". To build the Basic authentication value, create a string using the pattern:

USER_NAME:API_TOKEN

and then encode it using Base64. E.g. for above fake string, You should get Base64 value:

VVNFUl9OQU1FOkFQSV9UT0tFTg==

You have to also set Your Jenkins host, port and 2 jobs' paths.

After this setup and uploading the sketch - You are ready to use Your traffic lights.

Code is also available on GitHub.

Downloads

Last Words

To power on the device, just connect the device to any USB socket. It uses WiFi conection to access Internet so any working USB socket is OK - either computer port or charger. After a boot up and connecting to WiFi, Your traffic lights will start showing the current build status.

I find this traffic lights very usefull. They are standing next to my monitors in office and whenever red light lights up - I notice it immediately. I don't need to waste time to check the build statuses directly on Jenkins.

One improvement could be done by using some traffic lights toy instead of building one by myself from scratch (junk?).

I hope You find some inspiration to build Your own Jenkins integrated traffic lights.