BuildStatusTrafficLight: Difference between revisions

From RevSpace
Jump to navigation Jump to search
No edit summary
No edit summary
(11 intermediate revisions by the same user not shown)
Line 12: Line 12:
It can show the following statuses:
It can show the following statuses:
* <span style="background:#FF0000">red</span>: build has failed to compile
* <span style="background:#FF0000">red</span>: build has failed to compile
* <span style="background:#FFFF00">yellow</span>: build compiles but a unit test fails
* <span style="background:#FFFF00">yellow</span>: code compiles but a unit test fails
* <span style="background:#00FF00">green</span>: build is OK
* <span style="background:#00FF00">green</span>: code compiles and all unit tests are successful
* <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
* <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 ==
== Status ==
  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-11-02 Played with ESP8266 software, particular playing audio using the 1-transistor-circuit
   2018-10-30 Received that hardware, opened it up etc.
   2018-10-30 Received that hardware, opened it up etc.
TODO
* update the arduino code to also allow the status to be set over serial: I plan to use my basic "command interpreter" that I've also used in previous projects
* write a simple python script that polls the build server and updates the traffic light over serial
** figure out which URL I need to poll to achieve this, perhaps use a JenkinsAPI library? -> will this actually make it simpler, or does it complicate things?


== Hardware ==
== Hardware ==
The plan is to use an ESP8266 (e.g. Wemos D1 mini) along with a modified toy traffic light (see below).
I use an ESP8266 (Wemos D1 mini) along with a modified toy traffic light (see below).
Perhaps I'll need some kind of LED or bulb driver too.


Apparently, the ESP8266 can source about 12 mA and sink about 20 mA of current.
I'm using [https://aliexpress.com/item/verkeerslicht/32836170176.html this toy traffic light], modified for use with the ESP8266.
This is enough for a small LED, might need more, I'll just have to see what kind of LED/bulb is inside the toy traffic light.
It 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 removed the original circuit (8-pin chip).
I replaced the white LEDs with high-brightness coloured ones (red, orange, green).
The ESP8266 can officially 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 ...)
It would be better to actually put it in a common Vcc wire, because the ESP8266 can more easily sink current than it can source it.


I'm using [https://aliexpress.com/item/verkeerslicht/32836170176.html This one] , to be modified with the ESP8266.
I haven't put in the sound circuit yet, that would be on the RX pin along with usage of the ESP8266Audio library in software and the 1-transistor driving circuit.
It lights the lanterns in order, speaking some Chinese for each lantern.
The lanterns are basically white LEDs behind a colored piece of transparent plastic.


== Software ==
== Software ==
Line 38: Line 46:
It is written in C/C++ for Arduino for quick and easy development using existing libraries, like WifiManager, PubSubClient.
It is written in C/C++ for Arduino for quick and easy development using existing libraries, like WifiManager, PubSubClient.


The plan is to simply listen to an MQTT stream.
The initial plan is to simply listen to an MQTT stream.
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.
Another plan is to listen on the serial port and receive commands from there.
A python script running on a PC inside the LAN script polls the Jenkins server over ethernet and sends a command to the traffic light over serial.
 
=== Getting build status ===
 
To get the Jenkins build state, poll the following URL
  http://jenkins/job/<jobname>/lastBuild/api/json
and then look for the "result" field at the top level of the JSON, it can take on the following values
* "FAILURE"
* "UNSTABLE"
* "SUCCESS"


== 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]

Revision as of 15:55, 20 November 2018

Project BuildStatusTrafficLight
Stoplicht.jpg
A traffic light showing CI build status
Status Completed
Contact bertrik
Last Update 2018-11-20

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

 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 that hardware, opened it up etc.

TODO

  • update the arduino code to also allow the status to be set over serial: I plan to use my basic "command interpreter" that I've also used in previous projects
  • write a simple python script that polls the build server and updates the traffic light over serial
    • figure out which URL I need to poll to achieve this, perhaps use a JenkinsAPI library? -> will this actually make it simpler, or does it complicate things?

Hardware

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

I'm using this toy traffic light, modified for use with the ESP8266. It 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 removed the original circuit (8-pin chip). I replaced the white LEDs with high-brightness coloured ones (red, orange, green). The ESP8266 can officially 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 ...) It would be better to actually put it in a common Vcc wire, because the ESP8266 can more easily sink current than it can source it.

I haven't put in the sound circuit yet, that would be on the RX pin along with usage of the ESP8266Audio library in software and the 1-transistor driving circuit.

Software

Source code can be found on github.

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

The initial plan is to simply listen to an MQTT stream. Another plan is to listen on the serial port and receive commands from there. A python script running on a PC inside the LAN script polls the Jenkins server over ethernet and sends a command to the traffic light over serial.

Getting build status

To get the Jenkins build state, poll the following URL

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

and then look for the "result" field at the top level of the JSON, it can take on the following values

  • "FAILURE"
  • "UNSTABLE"
  • "SUCCESS"

External links