ruby – 有没有更好的方法从rake中运行capistrano任务?
发布时间:2020-12-17 03:43:22 所属栏目:百科 来源:网络整理
导读:我有一套rake任务,我需要在某些时候调用capistrano. Edwin Goei的 blog建议通过“sh”向capistrano猛烈抨击. 有更简单的方法吗?看起来你应该能够以编程方式调用适当的任务.提前致谢. 解决方法 是的,Capistrano可以通过编程方式访问命令行组件.但是,如果你想
|
我有一套rake任务,我需要在某些时候调用capistrano. Edwin Goei的
blog建议通过“sh”向capistrano猛烈抨击.
有更简单的方法吗?看起来你应该能够以编程方式调用适当的任务.提前致谢. 解决方法
是的,Capistrano可以通过编程方式访问命令行组件.但是,如果你想从rake任务中调用它们,你需要做一些额外的工作.
task :deploy
require 'rubygems'
require 'capistrano'
require 'capistrano/cli'
parameters = ["deploy"] # this is an array of the strings that come after
# cap on the command line. e.g.,# ["deploy","-S","revision=1024"] gives you local var
# revision in your deploy.rb.
# The following is required ONLY when you run Capistrano 2+ from Rake,# because Rake adds the methods from FileUtils to Object. FileUtils includes
# a method called symlink which interferes with Capistrano's symlink task.
Capistrano::Configuration::Namespaces::Namespace.class_eval { undef :symlink }
Capistrano::CLI.parse(parameters).execute!
end
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
