I was using capistrano 2 with my php project, where I used to define custom variables like this:
set :app_environment, "test"
And then I accessed it in my deploy tasks, e.g.:
run "echo '#{app_environment}' > #{releases_path}/#{release_name}/protected/config/mode.php"
Now in capistrano 3 I define this variable in my stage-specific config files. But I don't have them defined in my tasks:
undefined local variable or method `app_environment' for #<SSHKit::Backend::Netssh:0x007f92323d6988> config/deploy.rb:28:in `block (3 levels) in <top (required)>'
Unfortunately there's not much documentation on the newest version of capistrano and I'm not quite familiar with ruby, so I don't see the way how to do that properly.
The code should read:
run "echo '#{fetch(:app_environment)}' > #{releases_path}/#{fetch(:release_name)}/protected/config/mode.php"
Although even that is incorrect as run()
doesn't exist in Cap3, it's now execute()
, so:
execute "echo '#{fetch(:app_environment)}' > #{releases_path}/#{fetch(:release_name)}/protected/config/mode.php"
Beware constructing your command like this nothing will use the command map, or respect the within()
, as()
or with()
constructs.
This is now achieved via 'fetch':
fetch(:app_environment)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With