require 'net/scp' module Evrone module CI module Worker DockerScript = Struct.new(:app) do include Helper::Logger def call(env) if env.ssh && env.docker_repo_dir code = run_script(env) if code == 0 app.call env else code end else app.call env end end private def run_script(env) scp = ::Net::SCP.new(env.ssh.connection) script = [env.docker_repo_dir, ".ci_script.sh"].join("/") puts env.job.message.script.inspect scp.upload! StringIO.new(env.job.message.script), script env.ssh.spawn "env - bash #{script}", chdir: env.docker_repo_dir, &env.job.method(:add_to_output) end end end end end