Sha256: c59e365f597bb2bd43a1726857a637cd246bc9900b4512b899e6376620b88ec4

Contents?: true

Size: 716 Bytes

Versions: 9

Compression:

Stored size: 716 Bytes

Contents

module Shuttle
  class Hook
    def initialize(deploy)
      @deploy = deploy
    end

    def run(commands, allow_failures=false)
      [commands].flatten.compact.uniq.each do |cmd|
        execute(cmd, allow_failures)
      end
    end

    private

    def execute(cmd, allow_failures)
      @deploy.log %{Executing "#{cmd.strip}"}

      command = cmd

      if @deploy.ssh.directory_exists?(@deploy.release_path)
        command = "cd #{@deploy.release_path} && #{command}"
      end

      result = @deploy.ssh.run(command)

      if result.failure? && allow_failures == false
        @deploy.error("Failed: #{result.output}")
      else
        @deploy.stream_output(result.output)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta14 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta13 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta12 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta11 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta10 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta9 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta7 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta6 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta5 lib/shuttle/hook.rb