25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/tumugi/plugin/task/command.rb', line 25
def run
log "Execute command: #{command}"
begin
out, err, status = Open3.capture3(env, *Shellwords.split(command))
rescue => e
raise Tumugi::TumugiError, e.message
end
logger.info out unless out.empty?
logger.error err unless err.empty?
if status.exitstatus == 0
if output_file && _output
log "Save STDOUT into #{output.path}"
output.open('w') do |f|
f.print(out)
end
end
else
raise Tumugi::TumugiError, "Command failed: exit status is #{status.exitstatus}"
end
end
|