我正在尝试为 Capistrano 定义自定义方法,以在我的 cap 任务中使用。我可以定义方法,然后在任务中使用这些方法就好了,直到我尝试从命名空间任务中调用这些方法,因为 Capistrano 然后引发异常。
从命名空间任务调用时,名为的自定义命令capturecmd
会中断 Capistrano 的示例跟踪file:replace
。适用于任何非命名空间任务:
#⚡ cap local file:replace -s dir=./jel-ids/ -s f=deploy -s r=deployed -s ext=.bak
* 2013-02-13 13:34:08 executing `local'
* 2013-02-13 13:34:08 executing `file:replace'
Capfile:129:in `capturecmd': uninitialized constant Capistrano::Configuration::Open3 (NameError)
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/configuration/namespaces.rb:191:in `method_missing'
from Capfile:41:in `block (2 levels) in load'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/configuration/execution.rb:138:in `instance_eval'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/configuration/execution.rb:138:in `invoke_task_directly'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/configuration/callbacks.rb:25:in `invoke_task_directly_with_callbacks'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/configuration/execution.rb:89:in `execute_task'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/configuration/execution.rb:101:in `find_and_execute_task'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:46:in `block in execute_requested_actions'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:45:in `each'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:45:in `execute_requested_actions'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/cli/help.rb:19:in `execute_requested_actions_with_help'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:34:in `execute!'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/lib/capistrano/cli/execute.rb:14:in `execute'
from /usr/local/opt/rbenv/versions/1.9.3-p385/lib/ruby/gems/1.9.1/gems/capistrano-2.14.2/bin/cap:4:in `<top (required)>'
from /usr/local/opt/rbenv/versions/1.9.3-p385/bin/cap:23:in `load'
from /usr/local/opt/rbenv/versions/1.9.3-p385/bin/cap:23:in `<main>'
编辑:此外,如果有人可以建议扩展 Capistrano 的适当结构,以便我的自定义方法可以与 , 等的现有方法处于同一run
级别capture
。