How can I set Capistrano configuration paths?

Capistrano config and tasks paths can be explicitly defined, like so:


# default deploy_config_path is 'config/deploy.rb'
set :deploy_config_path, 'cap/deploy.rb'
# default stage_config_path is 'config/deploy'
set :stage_config_path, 'cap/stages'

# previous variables MUST be set before 'capistrano/setup'
require 'capistrano/setup'

# default tasks path is `lib/capistrano/tasks/*.rake`
# (note that you can also change the file extensions)
Dir.glob('cap/tasks/*.rb').each { |r| import r }

Here is the corresponding capistrano configuration structure:

├── Capfile
└── cap
    ├── stages
    │   ├── production.rb
    │   └── staging.rb
    ├── tasks
    │   └── custom_tasks.rb
    └── deploy.rb

Be aware that you will have to provide an absolute path, if you want your "deploy_config_path" to be "capistrano/deploy.rb". See this issue for more explanations and how to get an absolute path in Ruby.

Fork me on GitHub