diff --git a/lib/kamal/cli/base.rb b/lib/kamal/cli/base.rb index 45b1411e..7e5dd77b 100644 --- a/lib/kamal/cli/base.rb +++ b/lib/kamal/cli/base.rb @@ -133,7 +133,7 @@ module Kamal::Cli def run_hook(hook, **extra_details) if !options[:skip_hooks] && KAMAL.hook.hook_exists?(hook) - details = { hosts: KAMAL.hosts.join(","), command: command, subcommand: subcommand } + details = { hosts: KAMAL.hosts.join(","), roles: KAMAL.specific_roles&.join(","), command: command, subcommand: subcommand }.compact say "Running the #{hook} hook...", :magenta with_env KAMAL.hook.env(**details, **extra_details) do diff --git a/lib/kamal/cli/proxy.rb b/lib/kamal/cli/proxy.rb index ad189b8c..1ed17740 100644 --- a/lib/kamal/cli/proxy.rb +++ b/lib/kamal/cli/proxy.rb @@ -69,6 +69,7 @@ class Kamal::Cli::Proxy < Kamal::Cli::Base end end when "get" + on(KAMAL.proxy_hosts) do |host| puts "Host #{host}: #{capture_with_info(*KAMAL.proxy.boot_config)}" end diff --git a/test/integration/docker/deployer/app/.kamal/hooks/pre-connect b/test/integration/docker/deployer/app/.kamal/hooks/pre-connect index e17784a5..0fe4e378 100755 --- a/test/integration/docker/deployer/app/.kamal/hooks/pre-connect +++ b/test/integration/docker/deployer/app/.kamal/hooks/pre-connect @@ -1,4 +1,5 @@ #!/bin/sh echo "About to lock..." +env mkdir -p /tmp/${TEST_ID} && touch /tmp/${TEST_ID}/pre-connect diff --git a/test/integration/main_test.rb b/test/integration/main_test.rb index 0a918a78..3b56fbb3 100644 --- a/test/integration/main_test.rb +++ b/test/integration/main_test.rb @@ -9,8 +9,12 @@ class MainTest < IntegrationTest kamal :deploy assert_app_is_up version: first_version assert_hooks_ran "pre-connect", "pre-build", "pre-deploy", "pre-app-boot", "post-app-boot", "post-deploy" + assert_envs version: first_version + output = kamal :app, :exec, "--verbose", "ls", "-r", "web", capture: true + assert_hook_env_variables output, version: first_version + second_version = update_app_rev kamal :redeploy @@ -191,4 +195,15 @@ class MainTest < IntegrationTest assert container_ids(vm: vm).any? end end + + def assert_hook_env_variables(output, version:) + assert_match "KAMAL_VERSION=#{version}", output + assert_match "KAMAL_SERVICE=app", output + assert_match "KAMAL_SERVICE_VERSION=app@#{version[0..6]}", output + assert_match "KAMAL_COMMAND=app", output + assert_match "KAMAL_PERFORMER=deployer@example.com", output + assert_match /KAMAL_RECORDED_AT=\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ/, output + assert_match "KAMAL_HOSTS=vm1,vm2", output + assert_match "KAMAL_ROLES=web", output + end end