Reputation: 43401
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?
Upvotes: 16
Views: 13990
Reputation: 43401
Use system
instead of back-ticks:
system("EXAMPLE=something rake db:rebuild")
Upvotes: 4