How to set conditional variables in capistrano's deploy.rb?

234 views
Skip to first unread message

Saurav Shah

unread,
Apr 3, 2012, 2:11:47 PM4/3/12
to capis...@googlegroups.com

Snippets from my deploy.rb

task :prod1 do
  set :deploy_to, "/home/project/src/prod1"
end

task :prod2 do
  set :deploy_to, "/home/project/src/prod2"
end

I have 2 tasks like the above. Now instead of manually running either "cap prod1 deploy" or "cap prod2 deploy", I want to create a task "prod" which sets the required "deploy_to" based on the existence of a file on the server.

something like:

task :prod do
  if (A_FILE_IN_SERVER_EXISTS)
    set :deploy_to, "/home/project/src/prod2"
  else 
    set :deploy_to, "/home/project/src/prod1"
end

How do I do that?


Stackoverflow link: http://stackoverflow.com/questions/9996574/how-to-set-conditional-variables-in-capistranos-deploy-rb

Donovan Bray

unread,
Apr 4, 2012, 7:20:55 PM4/4/12
to capis...@googlegroups.com
Use 'capture' with a find bash command

Then you can use the variable in your if
--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en
Reply all
Reply to author
Forward
0 new messages