Code is included in this post! I’ve written a small ruby script for polling a bamboo server for (multiple) build results, playing sounds for success and failure. It even controls lava lamps connected to a AM12 power outlet through a CM11 controller using the X10 protocol. You may get these at framtidshuset. To send the signals through your serial port(yeah, I know! serial port) to your CM11 controller, you need a program that takes arguments like this ‘command A1 on’, where A1 is the lamp/AM12 code and ‘on’ is the opposite of ‘off’ :) I use windows and ActiveHome’s (HomeControl) x10com32.exe (ships with the CM11 if bought from Framtidshuset), and on Linux you would use the free ‘heyu’ program. I’ve used heyu before and promise you it works.
Bamboo must have the Rest API enabled, a property setting you find somewhere in the bamboo settings.
If you make one for say, Hudson, or Continuum or whatever, please let me now and I’ll post a link. Certainly you’d probably want to extend or rewrite the continuous_builder_lamp_controller.rb to better fit your needs, it’s not, you know, perfected ;) It’s agile and on-demand driven development! If you modify it, extend it, improve it, let me in on the details!
You might download the script as a zip bundle here, with sounds and everything. The ruby script itself might also be downloaded here, with a config file example here and here. The x10 program x10com32.exe may be downloaded from here (not responsible for external sites). Below is a picture of a red lava lamp after a broken build. The other one is blue, but should of course be green :) As soon as the build is fixed, the red lamp will switch off, the blue on and cheering will chime to the PC speakers (if you enable sounds).
Note: The script seem to hang every first time it is executed after a reboot. Kill it, and run again. If you solve it, let me know:)
For many, the source code above is sufficient to get going. For the rest of us, I’ll repeat myself
What do I need to get started?
- Power control system using the x10 protocol. ( Referred above)
- ActiveHome PC interface CM11G (I’m using the serial cable version, but the usb should work as well)
- Utstyrsmodul AM12G, one for each lamp (two for each lamp set)
- Lamps or whatever you’d like, using a power cord. As the lava lamps in the picture. Annoying red for critical builds is cool.
- A, preferable dedicated, PC for playing sounds and sending signals to the CM11G module.
- Ruby and it’s required libraries (use the amazing ‘gem install xx’)
- Bamboo build server with REST-requests enabled. (Settings in bamboo)
- The source code (referred to above)
How do I get it running with one lamp set?
First, follow the instructions to connect the CM11G, using the serial or usb cable. Set the AM12G codes, e.g. A1 and A2, and connect the lamps to them. Ensure the lamps are glowing. (Hitting the power switch of the lamps will “override” the switch in the AM12G so that the lamp may always be switched on. This is a “smart” feature of the module). Go to the installation directory of the Lamp control system, having the x10com32.exe and ensure that these commands switches the lamps on/off.
- x10com32.exe A1 off
- x10com32.exe A1 on
- x10com32.exe A2 off
- x10com32.exe A2 on
Now, you’re either having the biggest grin upon your face, or you’re pissed off. Relax, I’ve felt both. If you have problems, check this
- You’re using the correct serial port.
- The CM11G and AM12Gs are on the same power subnet (or something). Recommend using a unit with multiple power outlets on it, while testing. This ensures the signals aren’t disturbed, as the CM11G and AM11g communicates through the power grid(!).
- The AM12Gs have codes A1 or A2 (or whatever you chose)
- The computers power cord is plugged into the CM11G (haven’t tested the necessity of this, though)
The config files are the only ones you need to edit! They’re fairly self explanatory. The lamp_control success/failure codes are the same as the ones on your AM12G devices (here O1 and O2 instead of A1 and A2)
- For multiple lamp systems, create more config YAML files. We’ll provide the config files as input to the continuous integration lamp control system script.
- Multiple build_names defines that you want the unity of those affect one lamp set.
Check the two example files given (referred to above)!
Edit the config files and execute the script with
ruby continuous_builder_lamp_controller.rb config.yml config2.yml …
Have fun! May the lamps be green at all times!