Skip to content

Instantly share code, notes, and snippets.

@joakimk
Created April 3, 2009 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joakimk/89810 to your computer and use it in GitHub Desktop.
Save joakimk/89810 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/http'
require 'rexml/document'
@cc_server = 'your-cc-server'
include REXML
def build_green?
result = Net::HTTP.start(@cc_server, 8000) { |http| http.get('/XmlStatusReport.aspx') }
root = Document.new(result.body).root
root.elements.each do |e|
return false if e.attributes['lastBuildStatus'] == "Failure"
end
true
end
@build_is_broken = true
def green_build!
if @build_is_broken
@build_is_broken = false
puts 'Build was fixed.'
system "../tdtool --on 2 --off 3"
end
end
def red_build!
unless @build_is_broken
@build_is_broken = true
puts 'Build was broken.'
system "../tdtool --off 2 --on 3"
end
end
while true
begin
build_green? ? green_build! : red_build!
rescue
puts "Failed to get build status..."
sleep 10
end
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment