I have three Rake tasks invoked from another Rake task. The first Rake task requires that an environmental variable is set before it is executed.
The following works, however it means that I lose all the output from the task which is critical:
namespace :deploy do
task :staging => :environment do
`EXAMPLE=something rake db:rebuild`
Rake::Task["rake envs:push:staging"].invoke
Rake::Task["rake app:push:staging"].invoke
end
end
How can I invoke the first task with the environmental variable AND display its output to the terminal?
Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.
Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax. Rake has the following features: Rakefiles (rake's version of Makefiles) are completely defined in standard Ruby syntax. No XML files to edit.
ENV['EXAMPLE'] = 'something'
Rake::Task['db:rebuild'].invoke
Use system
instead of back-ticks:
system("EXAMPLE=something rake db:rebuild")
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