Skip to content

Instantly share code, notes, and snippets.

@marcusbaguley
Created July 11, 2011 00:06
Show Gist options
  • Save marcusbaguley/1075114 to your computer and use it in GitHub Desktop.
Save marcusbaguley/1075114 to your computer and use it in GitHub Desktop.
Hudson / Jenkins Remote Sound Player
require 'net/http'
last_build = true
new_build = false
while(1) do
xml = Net::HTTP.get(URI.parse('http://fiji.island:8080/api/xml?tree=jobs[name=ims_ci,lastBuild[result]]'))
puts xml
if xml == '<hudson><job><lastBuild></lastBuild></job></hudson>'
new_build = true
elsif xml =~ /job/
current_build_status = !!(xml =~ /SUCCESS/)
if current_build_status != last_build
puts 'status change'
if current_build_status
puts 'build fixed'
`aplay sound-archive/excelnt.wav`
else
puts 'build broken'
`aplay sound-archive/houston.wav`
end
elsif new_build
if !current_build_status
puts 'new build - still broken'
`aplay sound-archive/doh.wav`
else
puts 'new build - no status change'
`aplay sound-archive/bicyclebell.wav`
end
new_build = false
end
last_build = current_build_status
else
puts "Unknown Response #{xml}"
end
sleep(5)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment