Running all namespace tasks with Capistrano
I have a namespace with various tasks:
namespace: mytest do task: setup do; ... end; task: task1 do; ... end; task: task2 do; ... end; end
When I run cap mytest, I get the "backup" task does not exist.
How do I create a command that calls all tasks?
+2
collimarco
source
to share
2 answers
task: default do setup task1 task2 end
+3
collimarco
source
to share
In one project, I often had to call all tasks in a given namespace. Here is a simple monkey patch for a class Namespace
that will add a method run_all_tasks
. The method accepts an optional array except
, which must be a list of task names (as characters) to exclude.
module Capistrano
class Configuration
module Namespaces
class Namespace
def run_all_tasks(except = [])
except << :all
self.task_list(false).each do |task|
task.body.call unless except.include?(task.name)
end
end
end
end
end
end
The method will run tasks in the order in which they are defined. As with any monkey patch \ hack, use this method with care!
0
mikeycgto
source
to share