class Tumugi::Plugin::CommandTask
Public Instance Methods
output()
click to toggle source
# File lib/tumugi/plugin/task/command.rb, line 17 def output unless output_file.nil? @output ||= Tumugi::Plugin::LocalFileTarget.new(output_file) else nil end end
run()
click to toggle source
# 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