How to add an if staging check to Capistrano task?

2019-08-19 15:10发布

Right now in Capistrano I have it doing

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

Which echoes out "staging"

On the very next line I have

if fetch(:stage) == "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.

1条回答
狗以群分
2楼-- · 2019-08-19 16:04

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}"

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

if fetch(:stage) == :staging
查看更多
登录 后发表回答