Skip to content

Instantly share code, notes, and snippets.

@lefticus
Last active October 8, 2018 13:08
Show Gist options
  • Save lefticus/10914850 to your computer and use it in GitHub Desktop.
Save lefticus/10914850 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fileutils'
if ARGV.length < 4
puts "Usage: #{__FILE__} <buildfolder> [options] <testruntrueorfalse> <githubtoken> <repositoryname> (<repositoryname> ...)"
abort("Not enough arguments")
end
puts "starting CI system"
while true
begin
puts "Creating folder #{ARGV[0]}"
FileUtils.mkdir_p(ARGV[0])
puts "Cleaning up old decent_ci folder"
FileUtils.rm_rf("#{ARGV[0]}/decent_ci")
puts "Changing to folder #{ARGV[0]}"
FileUtils.cd(ARGV[0])
break
rescue => e
puts "Error setting up build folders, sleeping and trying again"
sleep 120
end
end
while !system("git clone https://github.com/lefticus/decent_ci")
puts "Unable to clone decent_ci repository. Sleeping and trying again";
sleep 120
end
puts "Successfully cloned decent_ci repository."
while true
puts "Updating decent_ci"
if system("cd decent_ci && git pull")
puts "Running ci.rb"
ci_args = ARGV[1..-1]
if !system("#{RbConfig.ruby}", "decent_ci/ci.rb", *ci_args)
puts "Unable to execute ci.rb script"
end
else
puts "Unable to update decent_ci repository"
end
puts "Sleeping"
sleep(300)
end
@lefticus
Copy link
Author

lefticus commented Jul 1, 2014

@Myoldmopar @kbenne I've updated the run_ci.rb script to be more robust to failure, and retry when necessary. It's optional to update your run_ci script, but it might help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment