gpt4 book ai didi

ruby - 有没有更好的方法从 rake 中运行 capistrano 任务?

转载 作者:数据小太阳 更新时间:2023-10-29 07:25:22 26 4
gpt4 key购买 nike

我有一组 rake 任务,我需要在某些时候调用 capistrano。 Edwin Goei 的 blog建议通过“sh”向 Capistrano 支付费用。

有没有更简单的方法?看起来您应该能够以编程方式调用适当的任务。提前致谢。

最佳答案

是的,Capistrano 可以通过编程方式访问命令行组件。但是,如果你想从抽取任务中调用它们,你需要做一些额外的工作。

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

关于ruby - 有没有更好的方法从 rake 中运行 capistrano 任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/966467/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com