FAILURE<\/result>/ then
puts
puts `curl -s #{ci_host}/lastBuild/console?token=botandrose`.match(/(.+)<\/pre>/m)[1]
puts
raise TestsFailedError, "#{ci_host}/#{get_last_build_number}/console"
when /ABORTED<\/result>/ then
raise TestsAbortedError, "#{ci_host}/#{get_last_build_number}/console"
when /SUCCESS<\/result>/ then
puts "Continuous integration: success! deploying to production"
else raise "Unknown response from CI server:\n#{response}"
end
end
private
def heroku?
`git remote -v`.include? "production\tgit@heroku.com:"
end
def ci_host
"http://botandrose:thecakeisalie!@ci.botandrose.com/job/#{project_name}"
end
def has_ci?
`curl -s -I #{ci_host}/?token=botandrose` =~ /\b200 OK\b/
end
def start_ci
`curl -s -I -X POST #{ci_host}/build?token=botandrose`
end
def get_last_build_number
response = `curl -s #{ci_host}/lastBuild/api/xml?token=botandrose`
response.match(/(\d+)<\/number>/)[1].to_i
end
def get_last_time_elapsed
response = `curl -s #{ci_host}/lastStableBuild/api/xml?token=botandrose`
response.match(/(\d+)<\/duration>/)[1].to_i / 1000
end
def ensure_sanity!(dirty_ok = false)
auto_update!
check_dependencies
raise NotInProjectRootError unless File.directory? ".git"
raise OnMasterBranchError if current_branch == "master"
raise WorkingTreeDirtyError unless `git status`.include? "working directory clean" unless dirty_ok
end
end