Skip to content

Instantly share code, notes, and snippets.

@bradland
Last active Oct 29, 2019
Embed
What would you like to do?
# Server is defined in stage file deploy/staging.rb
# server 'staging.example.com', user: 'staginguser', roles: %i(app db web)
# Expect `say_hello` task to output:
# echo 'hello from "staginguser"'
# What `say_hello` task actually outputs:
# echo 'hello from nil'
task :say_hello do
on roles(:app) do
execute "echo 'hello from #{fetch(:user).inspect}'"
end
end
# By inspecting the output of `Capistrano::Configuration.env`, we can see
# that the server user is in the servers collection under configuration, but
# this variable is not exposed in the variables available through `fetch`.
namespace :dump do
task :env do
pp Capistrano::Configuration.env
end
task :servers do
pp Capistrano::Configuration.env.servers
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment