How to add an if staging check to Capistrano task?

巧了我就是萌 提交于 2019-12-13 04:09:08

问题


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:


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


来源:https://stackoverflow.com/questions/49677374/how-to-add-an-if-staging-check-to-capistrano-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!