Skip to content

Cory Foy

Organizational agility through intersecting business and technology

Menu
  • FASTER Fridays
  • Mapping Mondays
  • Player Embed
  • Search Videos
  • User Dashboard
  • User Videos
  • Video Category
  • Video Form
  • Video Tag
Menu

Build Status Lamp with Ruby and TeamCity

Posted on October 3, 2008 by Cory Foy

Recently at work we got our new build status light setup. We’re using TeamCity as our Continuous Integration Server, MSBuild as the build script, and a homemade Ruby Script to control the lamp.

The setup sits in our team room and looks like this:

DSC_1028

The Build Lamp (a red lava lamp in this case) is controlled by an X10 Transceiver:

 

DSC_1030

I have a little X10 transmitter attached to the serial port of the computer you see. It’s basically the setup from the Firecracker kit on X10.com. To check the status, we enabled the status widget feature of TeamCity, and I wrote a simple Ruby script to parse the widget using Why’s awesome Hpricot parser and the CM17A X10 Ruby code from Rubyforge. That script is available for download but is just:

require 'hpricot'
require 'open-uri'
require 'x10/cm17a'

def there_are_failing_builds()
retry_count = 0
begin
doc = Hpricot(open("http://teamcity:8080/externalStatus.html"))
failingBuildElements = doc.search("//img[@title='Build configuration is failing']")
return (failingBuildElements.length > 0)
rescue
if retry_count < 3
retry_count += 1
puts "Network not available. Sleeping for 10 seconds then retrying"
sleep 10 #Wait for a bit to see if the network will come up
retry
else
puts "Could not open web page (Network is down?)"
return false
end
end
end

def turn_on_lamp()
puts "BUILD BROKEN! Turning On Lamp"
#Do it twice because sometimes the first doesn't take
X10.device('C1').on
X10.device('C1').on
end

def turn_off_lamp()
#Do it twice because sometimes the first doesn't take
puts "Build A-Ok! Turning off lamp"
X10.device('C1').off
X10.device('C1').off
end

puts "Welcome to the Build Monitor"

while(true)
if(there_are_failing_builds())
turn_on_lamp()
else
turn_off_lamp()
end
puts "Next status check in 60 seconds..."
sleep 60
end

We’ll also play a build break sound (the team has chose the Macarena for now), but sound isn’t working on that machine yet.

Happy hacking!

1 thought on “Build Status Lamp with Ruby and TeamCity”

  1. Pingback: Top 5 Build Failure Sounds | Scrumology

Comments are closed.

© 2025 Cory Foy | Powered by Superbs Personal Blog theme