Capistrano:在远程部署后有条件地运行命令
我想在部署完成后删除远程上的一些文件夹。我目前正在使用
task :set_permissions do
parallel do |session|
session.when "in?(:xb_test)", "cat #{deploy_to}test.htaccess >> #{current_path}/.htaccess"
end
两个问题,这是执行此操作的最佳方法吗?如何在多个函数上运行这种语句而无需编写重复代码?
session.when "in?(:xb_test)" ...
session.when "in?(:xb_dev)" ...
session.when "in?(:xb_live)" ...
任何帮助将不胜感激,因为我对 Capistrano 还很陌生
I want to remove some folders on the remote once deploy has completed. I am currently using
task :set_permissions do
parallel do |session|
session.when "in?(:xb_test)", "cat #{deploy_to}test.htaccess >> #{current_path}/.htaccess"
end
Two questions really, is this the best way to do this and how can I run this kind of statement on multiple functions without having to write repeat code?
session.when "in?(:xb_test)" ...
session.when "in?(:xb_dev)" ...
session.when "in?(:xb_live)" ...
Any help would be appreciated as I'm pretty new to Capistrano
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于你的第一个问题,“这是最好的方法吗?” :
我认为这不是最好的方法。
“test”“dev”和“live”嗯......看起来你正在部署到不同的阶段,那么我最好使用 https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
关于你的第二个问题,“我怎样才能在多个函数上运行这种语句而无需编写重复代码?":
capistrano deploy.rb只是一个ruby文件,你可以使用一个方法
,然后
About your first question, "is this the best way to do this ?" :
I don't think this is the best approach.
"test" "dev" and "live" uhm... it looks like you are deploying to different stages, then I would better use https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
About your second question, "how can I run this kind of statement on multiple functions without having to write repeat code ?":
capistrano deploy.rb is just a ruby file, you can use a method
and then