Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a list of the set variables in Capistrano 3

I wonder if there is a simple way to get all the currently set variables in Capistrano 3?

So if I have:

set :user, "deploy"
set :application, "someapp"

I would like to get something like:

all_variables # => { user: "deploy", application: "someapp", ... }

Thanks

like image 767
Dmitry Sokurenko Avatar asked May 03 '15 11:05

Dmitry Sokurenko


2 Answers

I was looking for the same thing and found Capistrano::Configuration.env.

namespace :dump do
  task :env do
    pp Capistrano::Configuration.env
  end
end

This should allow you to view all :set variables by calling cap dump:env.

Use fetch to get the values.

Fetch mention in getting started guide

Quick Edit: To get exactly what you're looking for try:

all_variables = Capistrano::Configuration.env.instance_eval{ @config }
like image 79
zekeatjackrabbit Avatar answered Nov 04 '22 19:11

zekeatjackrabbit


This works well

vars = Capistrano::Configuration
  .env
  .instance_eval { @variables }
  .trusted_keys
like image 1
Dino Reic Avatar answered Nov 04 '22 21:11

Dino Reic