Sha256: 82c82838387178c1a57c967f789f7f60985b1bde631e1866339fda6306bc0db1

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

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


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre0 lib/evrone/ci/worker/middlewares/docker_script.rb