class Raykit::Runner
Public Class Methods
get_build_yaml(directory)
click to toggle source
# File lib/raykit/runner.rb, line 32 def self.get_build_yaml(directory) yaml='' Dir.chdir(directory) do if(File.exist?('.gitlab-ci.yml')) yaml = File.open('.gitlab-ci.yml').read end end yaml end
run(git_url)
click to toggle source
# File lib/raykit/runner.rb, line 5 def self.run(git_url) commands=Array.new() local_dir=Dir.mktmpdir('runner') puts 'local_dir : ' + local_dir commands << Raykit::Command.new("git clone #{git_url} #{local_dir}") Dir.chdir(local_dir) do commands << Raykit::Command.new("git log -n 1") yaml=get_build_yaml(local_dir) build_hash=YAML.load(yaml) build_commands=Raykit::Command.parse_yaml_commands(yaml) if(build_hash.key?('image')) image=build_hash['image'] build_commands.insert(0,'cd home') build_commands.insert(1,"git clone #{git_url} build") build_commands.insert(2,'cd build') build_commands_string=build_commands.join(';'); commands << Raykit::Command.new("docker run #{image} sh -c \"#{build_commands_string}\"") else build_commands.each{|cmd_string| commands << Rakkit::Command.new(cmd_string) } end end FileUtils.rm_rf(local_dir) commands end