Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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