BuildStatusTrafficLight: Difference between revisions

From RevSpace
Jump to navigation Jump to search
No edit summary
 
(37 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Project
{{Project
  |Name=BuildStatusTrafficLight
  |Name=BuildStatusTrafficLight
  |Picture=BuildStatusTrafficLight.jpg
  |Picture=stoplicht.jpg
  |Omschrijving=A traffic light showing CI build status
  |Omschrijving=A traffic light showing CI build status
  |Status=Initializing
  |Status=Completed
  |Contact=bertrik
  |Contact=bertrik
}}
}}
Line 11: Line 11:


It can show the following statuses:
It can show the following statuses:
* green: build is OK
* <span style="background:#FF0000">red</span>: build has failed to compile
* yellow: build compiles but a unit test fails  
* <span style="background:#FFFF00">yellow</span>: code compiles but a unit test fails
* red: build has failed to compile
* <span style="background:#00FF00">green</span>: code compiles and all unit tests are successful
* yellow flashing: build status unknown, e.g. still starting up, connection problem, or we receive a status we don't understand
* <span style="text-decoration:blink">yellow flashing</span>: build status unknown, e.g. still starting up, connection problem, or we receive a status we don't understand
 
== Status ==
It works!
 
  2018-11-22 Added python script to poll the Jenkins build server and control the traffic light over its serial connection
  2018-11-20 Added command interpreter for control over serial port, removed audio
  2018-11-18 Soldered new, brighter LEDs into it and connected the ESP8266, no sound yet
  2018-11-02 Played with ESP8266 software, particular playing audio using the 1-transistor-circuit
  2018-10-30 Received the hardware, opened it up etc.
 
Future, things I would do better next time:
* configure LEDs for common anode, so the ESP8266 sinks current instead of sourcing it
* rethink audio, the audio using ESP8266Audio library uses pin Rx, making serial comms impossible, perhaps just use PWM?


== Hardware ==
== Hardware ==
The plan is to use an ESP8266 along with a modified toy traffic light.
I use an ESP8266 (Wemos D1 mini) along with a [https://aliexpress.com/item/verkeerslicht/32836170176.html modified toy traffic light].
For example a Wemos D1 mini.
 
The toy traffic light lights the lanterns in order, speaking some Chinese for each lantern.
The lanterns are basically white LEDs behind a colored piece of transparent plastic.


Bonus point if we can add sound when the status changes.
I replaced the white LEDs with high-brightness coloured ones (red, orange, green).
I removed the original circuit (8-pin chip) and put in an ESP8266 to accept commands and control the LEDs.
It can source about 12 mA and sink about 20 mA of current,
I'm using a single 150 ohm resistor in the common ground wire of the LEDs (couldn't find a 100 ohm resistor at the space ...)


[https://aliexpress.com/item/andere/32836170176.html This one] has been ordered, to be modified with the ESP8266.
The toy traffic light features a built-in speaker. I haven't put in a sound circuit yet.
Usage of the ESP8266Audio library in software is problematic because this library sends audio over pin Rx, making serial communication difficult.


== Software ==
== Software ==
=== ESP8266 ===
Source code can be found [https://github.com/bertrik/BuildStatusLight on github].
Source code can be found [https://github.com/bertrik/BuildStatusLight here].
 
It is written in C/C++ for Arduino for quick and easy development.
 
The traffic light listens on the serial port to receive commands (like 'set 1'),
A python script running on a PC inside the LAN script polls the Jenkins server over ethernet.


It is written in C/C++ for Arduino for quick and easy development using existing libraries, like WifiManager, PubSubClient.
=== Getting build status ===


The plan is to simply listen to an MQTT stream.
To get the Jenkins build state, poll the following URL to receive JSON status data
To keep things secure and secret as much as possible, I plan to use an encrypted link to the MQTT server along with a username/password.
  http://jenkins/job/jobname/lastBuild/api/json
where jobname is the name of your build job.
Then look for the value of the "result" field at the top level of the JSON, it can take on the following values:
* "FAILURE" mapped to red light
* "UNSTABLE" mapped to yellow light
* "SUCCESS" mapped to green light
* null, in case a build is still in progress, mapped to yellow flashing


== External links ==
== External links ==
* [https://wiki.jenkins.io/display/JENKINS/Traffic+Light+Plugin Jenkins traffic light plugin] seems to have the wrong kind of interface, designed to directly drive a bunch of wireless 230V sockets instead of just sending the information like I need
* [https://wiki.jenkins.io/display/JENKINS/Traffic+Light+Plugin Jenkins traffic light plugin] seems to have the wrong kind of interface, designed to directly drive a bunch of wireless 230V sockets instead of just sending the information like I need
* [https://jobs.zalando.com/tech/blog/signalling-your-jenkins-build-status-with-a-mini-usb-traffic-light Signalling Your Jenkins Build Status with a Mini USB Traffic Light]
* [https://jobs.zalando.com/tech/blog/signalling-your-jenkins-build-status-with-a-mini-usb-traffic-light Signalling Your Jenkins Build Status with a Mini USB Traffic Light]

Latest revision as of 17:54, 7 January 2019

Project BuildStatusTrafficLight
Stoplicht.jpg
A traffic light showing CI build status
Status Completed
Contact bertrik
Last Update 2019-01-07

Introduction

The end result of this project is a traffic light that shows the status of a software build.

It can show the following statuses:

  • red: build has failed to compile
  • yellow: code compiles but a unit test fails
  • green: code compiles and all unit tests are successful
  • yellow flashing: build status unknown, e.g. still starting up, connection problem, or we receive a status we don't understand

Status

It works!

 2018-11-22 Added python script to poll the Jenkins build server and control the traffic light over its serial connection
 2018-11-20 Added command interpreter for control over serial port, removed audio
 2018-11-18 Soldered new, brighter LEDs into it and connected the ESP8266, no sound yet
 2018-11-02 Played with ESP8266 software, particular playing audio using the 1-transistor-circuit
 2018-10-30 Received the hardware, opened it up etc.

Future, things I would do better next time:

  • configure LEDs for common anode, so the ESP8266 sinks current instead of sourcing it
  • rethink audio, the audio using ESP8266Audio library uses pin Rx, making serial comms impossible, perhaps just use PWM?

Hardware

I use an ESP8266 (Wemos D1 mini) along with a modified toy traffic light.

The toy traffic light lights the lanterns in order, speaking some Chinese for each lantern. The lanterns are basically white LEDs behind a colored piece of transparent plastic.

I replaced the white LEDs with high-brightness coloured ones (red, orange, green). I removed the original circuit (8-pin chip) and put in an ESP8266 to accept commands and control the LEDs. It can source about 12 mA and sink about 20 mA of current, I'm using a single 150 ohm resistor in the common ground wire of the LEDs (couldn't find a 100 ohm resistor at the space ...)

The toy traffic light features a built-in speaker. I haven't put in a sound circuit yet. Usage of the ESP8266Audio library in software is problematic because this library sends audio over pin Rx, making serial communication difficult.

Software

Source code can be found on github.

It is written in C/C++ for Arduino for quick and easy development.

The traffic light listens on the serial port to receive commands (like 'set 1'), A python script running on a PC inside the LAN script polls the Jenkins server over ethernet.

Getting build status

To get the Jenkins build state, poll the following URL to receive JSON status data

 http://jenkins/job/jobname/lastBuild/api/json

where jobname is the name of your build job. Then look for the value of the "result" field at the top level of the JSON, it can take on the following values:

  • "FAILURE" mapped to red light
  • "UNSTABLE" mapped to yellow light
  • "SUCCESS" mapped to green light
  • null, in case a build is still in progress, mapped to yellow flashing

External links