Introduction
In the agile software development world, continuous integration is a widely used practice and it is very helpful in building quality software. It is vital to bring failed builds to the attention of responsible developers as quickly as possible. This problem can be easily solved in a fun way by using YeeLight WiFi Bulb for agile development team.
Architecture
The system starts with an on-premise Continuous Integration Server with building systems (Jenkins, GitLab CI), YeeLight WIFI Bulb, program deployed PC.
Build a customized program to collect the Build events from the Build Server, then invoke YeeLight Open API to control the WIFI Bulb for ON/OFF and color change.
YeeLight WIFI Bulb (Color)
Hardware
YeeLight Led WIFI Bulb (Color) is one of products from Qingdao Yeelink Information Technology Co., Ltd.
Yeelink is an emerging innovative enterprise that was founded in 2012 with the help of the American incubator SOSven-tures.
Features
- Works with Amazon Alexa ( voice control ), IFTTT MIJIA,
- Wi-Fi access – control your lights by smartphone app through home Wi-Fi
- 16 million colors bulb, dimmable and Color temperature range 1700k-6500k
- Set time schedules and Countdowns, energy efficient
- Music sync and Group control via app, no hub is required
For more YeeLight Led WIFI Bulb(Color) product details, please refer Product Introduction.
Configuration
To activate the YeeLight WIFI Bulb, download “YeeLight” from the App Store or the Google Store. Follow the below steps to initialize the bulb and enable the “Development” mode.
1.Scan the QR code to download the Yeelight Application
2.Add Yeelight smart LED device
3.Turn on [Developer Mode] in the settings page
OpenAPI
The WIFI Bulb has two control mode, one is remote controlled through the internet. The other is locally controlled through your local WIFI network. A 3rd party API is used to control the bulb under the same local WIFI network. Below is a diagram of the bulb’s discover procedure for the local network environment.
The bulb signal broadcasts and can be discovered as a UDP protocol. Control is through TCP. Following is the list of all supported methods and parameters.
Yeelight WiFi Light Inter-Operation Specification: API Document
Continuous Integration System Integration
Jenkins
Jenkins provides a machine-consumable remote access API to its functionalities. Currently, it comes in three flavors:
- XML
- JSON with JSONP support
- Python
Remote access API is offered in a REST-like style. That is, there is no single entry point for all features, and instead, they are available under the “…/api/” URL where “…” portion is the data that it acts on.
Remote API can be used to do things like these:
- retrieve information from Jenkins for programmatic consumption.
- trigger a new build
- create/copy jobs
We will use the Jenkins API to retrieve the latest build results.
http://user:password@<Jenkins URL>/job/<job name>/lastBuild/api/xml?<Filter_Condition>
Jenkins Remote Access API
Jenkins Remote Access API Java demo
Example
Request command:
Curl http://10.2.7.84:9000/job/Bosch%20Prototype%20Production/lastBuild/api/xml?tree=*
Response from Jenkins server:
GitLab CI
A pipeline is a group of jobs that get executed in stages (batches). All of the jobs in a stage are executed in parallel (if there are enough concurrent Runners), and if they all succeed, the pipeline moves on to the next stage. If one of the jobs fails, the next stage is not (usually) executed. You can access the pipelines page in your project’s Pipelines tab.
In the following image, you can see that the pipeline consists of four stages (build, test, staging, production) each one having one or more jobs.
GitLab Pipelines API helps to retrieve the latest pipeline result from GitLab CI.
Create an access token for your API to invoke, through the below GitLab screen from “Settings” menu.
Example
Request command:
curl –header “PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK” “https://gitlab.example.com/api/v4/projects/1/pipelines”
Response from GitLab Server:
Java Example Code
This Java example code implemented the below functions:
- Invoke Jenkins Latest build API to retrieve job result
- Discover YeeLight WIFI Bulb from local network
- Change Bulb color according to Job result
The code refers from GitHub Death111’s YeelightJava project which encapsulates the YeeLight HTTP methods and library.
Running Result: