Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run rake tasks in sequence

Tags:

ruby

rake

I have rake tasks which i want to run in proper sequence.

I want to run one rake task which run other rake tasks in proper sequence.

How may i do that?

like image 524
krunal shah Avatar asked Jan 01 '26 22:01

krunal shah


1 Answers

you should consider defining dependencies between your tasks like this

  task :primary => [:secondary]

  task :secondary do
    puts "Doing Secondary Task" 
  end

But if you really, really need to call the tasks directly you can use invoke to call another task

  task :primary do
    Rake::Task[:secondary].invoke
  end

  task :secondary do
    puts "Doing Secondary Task" 
  end

see also here

like image 175
Nikolaus Gradwohl Avatar answered Jan 03 '26 16:01

Nikolaus Gradwohl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!