如何在Capistrano任务中添加if分期检查? [英] How to add an if staging check to Capistrano task?

查看:69
本文介绍了如何在Capistrano任务中添加if分期检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在在Capistrano中,我正在执行

Right now in Capistrano I have it doing

execute "echo #{fetch(:stage)}"

其中回显了暂存

下一行我有

if fetch(:stage) == "staging"

从不等于true。我尝试将其更改为,如果 staging == staging 并进入它的正文。呃,给出什么以及如何检查只运行一行分段代码。

Which never equals true. I tried changing it to if "staging == "staging" and it enters the body of it. Uh, what gives and how do I do a check to only run one line of code for staging.

推荐答案

fetch(:stage)符号(自从我使用capistrano已经有一段时间了。)要验证这一点,请使用更精确的字符串表示形式:

fetch(:stage) is likely a symbol (it's been a while since I used capistrano). To verify this, use a more precise string representation:

execute "echo #{fetch(:stage).inspect}"

我敢打赌它会打印:staging 。在这种情况下,您需要

I'm betting it will print :staging. In which case you need to do

if fetch(:stage) == :staging

这篇关于如何在Capistrano任务中添加if分期检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆