Get list of given variables in Capistrano 3

I wonder if there is an easy way to get all 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", ... }

      

thank

+3


source to share


1 answer


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

.

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

      

This will allow you to view all the variables :set

by calling cap dump:env

.

Use fetch

to get values.



Retrieve Mention in Getting Started Guide

Quick edit: To get exactly what you're looking for, follow these steps:

all_variables = Capistrano::Configuration.env.instance_eval{ @config }

      

+3


source







All Articles