Some time ago I’ve encountered a LIFX smart bulbs. These are the bulbs with a chip inside - 50% bulb, 50% chip. There’re mobile applications for easy configuration and remote control of the bulb. Nothing special here, it simply works and is very convenient to have such bulbs in dormitory.
Brilliant idea time
99% of ideas which come to our minds either were already implemented by someone else or they are shit.
And as it always happens, developer inside me generated an idea, which was implemented by someone else already.
The idea was to
connect a LIFX bulb to Jenkins server and update bulb color according to a job state.
Before starting to work on such Jenkins plugin, I’ve searched for analogs in G and first links pointed me to existing Jenkins plugin and a blog post from
Michael Neale, author of this plugin, how he did it. Michael created a plugin which does exactly what I had in my mind.
At this point I had to 2 options:
- forget about the idea and give up
- improve existing plugin.
First option is always easy and effortless. But it’s not our way.
Improvement of existing plugin
Existing LIFX notifier plugin 0.2 version did its job really well and I was able to connect my bulb to Jenkins and test it. But it wasn’t complete and configurable at all (no possibility to change the colors).
First, I read Jenkins contribution guidelines, which encourage developers to improve existing plugins (if any) and not create other versions of plugins with similar functionality. Then
I’ve contacted Michael Neale, plugin author, via email and kindly asked for the contributor access in github for existing plugin version. After short discussion about my plans on this plugin, Michael added me as a contributor to github repo and wished me good luck. Thanks Michael
Everything I wanted to improve in LIFX notifier plugin is to add possibility to customize the colors (
build success and
build failure). This is not a hard task actually. 1000+ plugins were developed for Jenkins by the community. It means that I can do that as well. Good for me that I’ve used some plugins already which had similar UI which I planned to add to LIFX notifier. Here’re some of them:
These plugins + Jenkins plugin development documentation + Jelly components helped me to “understand better Jenkins architecture”, “how Jenkins plugins work in general”, “how to create UI of the plugin”, “how to subscribe to Jenkins job state changes using appropriate extension points”.
In a few weeks I’ve finished plugin modifications and covered with unit tests its major parts. As result plugin obtained a UI configuration section in
Post-build Actions which is self descriptive:
Last step was to prepare new plugin version and publish it to the world. Jenkins “Hosting plugins” document describes step by step process of how to publish a plugin. This includes many steps which should be respected very carefully.
What I’ve learned
It was my first experience in Jenkins plugins development. I should say that steep learning curve is high enough, and sometimes is really hard to find answers on appearing questions. But in general it’s all about
Maven and it’s a lot of fun developing Jenkins plugins.
Check plugin wiki page for more information.