Skip to content

Commit

Permalink
Merge pull request theforeman#19 from doddo/master
Browse files Browse the repository at this point in the history
adding STDERR to the error pop up
  • Loading branch information
domcleal committed Dec 9, 2014
2 parents 012d2b4 + 863e4cc commit 4ee9513
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/foreman_hooks/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ def render_hook_json

def exec_hook(*args)
logger.debug "Running hook: #{args.join(' ')}"
success = if defined? Bundler && Bundler.responds_to(:with_clean_env)
Bundler.with_clean_env { exec_hook_int(render_hook_json, *args) }
else
exec_hook_int(render_hook_json, *args)
end.success?

success, output = if defined? Bundler && Bundler.responds_to(:with_clean_env)
Bundler.with_clean_env { exec_hook_int(render_hook_json, *args) }
else
exec_hook_int(render_hook_json, *args)
end
# Raising here causes Foreman Orchestration to correctly show error bubble in GUI
raise ForemanHooks::Error.new "Hook failure running `#{args.join(' ')}`: #{$?}" unless success
raise ForemanHooks::Error.new "Hook failure running `#{args.join(' ')}`: #{$?} #{output}" unless success
success
end

Expand All @@ -49,6 +48,6 @@ def exec_hook_int(stdin_data, *args)
[output, $?]
end
logger.debug "Hook output: #{output}" if output && !output.empty?
status
[status.success?, output]
end
end

0 comments on commit 4ee9513

Please sign in to comment.