Sha256: 95ea02381f4578d337b9585967dce455abb019415aafff5c1df8132335be2a38

Contents?: true

Size: 763 Bytes

Versions: 6

Compression:

Stored size: 763 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
        if !result.output.empty?
          @deploy.stream_output(result.output)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.3 lib/shuttle/hook.rb
shuttle-deploy-0.2.2 lib/shuttle/hook.rb
shuttle-deploy-0.2.1 lib/shuttle/hook.rb
shuttle-deploy-0.2.0 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta16 lib/shuttle/hook.rb
shuttle-deploy-0.2.0.beta15 lib/shuttle/hook.rb