Skip to content

Commit 3628eca

Browse files
authored
Merge pull request #753 from basecamp/dump-hook-output-on-failure
Include error message on failure
2 parents 5e492ec + 67a2d5e commit 3628eca

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/kamal/cli/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def run_hook(hook, **extra_details)
158158
say "Running the #{hook} hook...", :magenta
159159
run_locally do
160160
execute *KAMAL.hook.run(hook, **details, **extra_details)
161-
rescue SSHKit::Command::Failed
162-
raise HookError.new("Hook `#{hook}` failed")
161+
rescue SSHKit::Command::Failed => e
162+
raise HookError.new("Hook `#{hook}` failed:\n#{e.message}")
163163
end
164164
end
165165
end

test/cli/build_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class CliBuildTest < CliTestCase
5151
test "push pre-build hook failure" do
5252
fail_hook("pre-build")
5353

54-
assert_raises(Kamal::Cli::HookError) { run_command("push") }
54+
error = assert_raises(Kamal::Cli::HookError) { run_command("push") }
55+
assert_equal "Hook `pre-build` failed:\nfailed", error.message
5556

5657
assert @executions.none? { |args| args[0..2] == [ :docker, :buildx, :build ] }
5758
end

0 commit comments

Comments
 (0)