Class: Gitlab::QA::Docker::Shellout

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/docker/shellout.rb

Defined Under Namespace

Classes: StatusError

Class Method Summary collapse

Class Method Details

.execute!(command) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/qa/docker/shellout.rb', line 9

def self.execute!(command)
  puts "Running shell command: `#{command}`"

  Open3.popen2e(command.to_s) do |_in, out, wait|
    out.each do |line|
      puts line

      yield line, wait if block_given?
    end

    if wait.value.exited? && wait.value.exitstatus.nonzero?
      raise StatusError, "Docker command `#{command}` failed!"
    end
  end
end