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)
Config files
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!

October 7, 2008 at 12:02 pm |
Hi there
I am tring to get the script working but get the following error.
C:\ruby\bin>ruby C:\ruby\samples\ContinuousIntegrationLampControl\continuous_builder_lamp_controller.rb
C:/ruby/samples/ContinuousIntegrationLampControl/continuous_builder_lamp_controller.rb:3:in `reqire’: no such file to load — win32/sound (LoadError)
from C:/ruby/samples/ContinuousIntegrationLampControl/continuous_builder
_lamp_controller.rb:3
I downloaded the win32 one-click install for the install of ruby on the XP machine.
Ww
October 7, 2008 at 1:27 pm |
Hey! I did a test myself right now, on a fresh xp install (through vmware on my mac). I install the Ruby 1.8.6 One-Click Installer (http://www.ruby-lang.org/en/downloads/). Then using irb i checked that I could play the sounds. Didn’t even require additional gems to be installed!
C:\dev\ContinuousIntegrationLampControl>irb
irb(main):001:0> config = YAML::load(File.open(‘config.yml’))
=> {“lamp_control”=>{“command”=>”x10com32.exe”, “success”=>”B1″, “failure”=>”B2″
}, “sound”=>{“success”=>["sounds/cash_register.wav"], “failure”=>["sounds/glass_
break.wav"]}, “bamboo”=>{“username”=>”bamboouser”, “build_names”=>["AB-AB"], “ba
mboo_url”=>”http://:/api/rest”, “password”=>”bamboopwd”}}
irb(main):002:0> config['sound']['success'].each do |s|
irb(main):003:1* Sound.play(s)
irb(main):004:1> end
NameError: uninitialized constant Sound
from (irb):3
from (irb):2:in `each’
from (irb):2
irb(main):005:0> require ‘win32/sound’
=> true
irb(main):006:0> include Win32
=> Object
irb(main):007:0> config['sound']['success'].each do |s|
irb(main):008:1* Sound.play(s)
irb(main):009:1> end
=> ["sounds/cash_register.wav"]
irb(main):010:0>
and the cash money chimes in the room!
I recommend you starting the script in the same directory as the script, for you: C:\ruby\samples\ContinuousIntegrationLampControl
as it will load the file ‘config.yml’ (relative path)
As there are unlogical spelling errors in your comment I suspect you’ve manually rewrote it here. Try irb and report back the results