General settings for deployment in deploy.rb Capistrano

Posted by : on

Category : Capistrano

Here some general settings and use of them in capistrano deployment.

Set_scm: Set protocol to copy code from your repository to server.

set: ‘git’ // git protocol will used for deployment.

Set repository:

set path of your git repository.

Deploy_via :

This is very important setting. There are two ways to set this variable

  • Set to copy :

     set :deploy_via, :copy
    

this will copy all code with all meta data of repository like branch info n all.This will be a slow process because capistrano will perform a scp from your repository to server.

  • Set to export:

    set :deploy_via, :export
    

This is faster a bit because it will clone repository to the server it leave metadata of the repository.

Set branch: Set default branch to be deployed

There are many ways you can set it like:

  • Set it manually: Just hard code the branch name.
    set :branch ,'branch_name'
  • Ask before deployment: Use Capistrano::CLI.ask to take branch name at deployment time.
set :branch do
default_branch = Capistrano::CLI.ask('Enter branch name')
end

Use current branch:

You can use current working branch like:

  set :branch do
   default_branch = `git rev-parse --abbrev-ref HEAD`.chomp
  end

These are some common settings to keep in mind before writing a deployment script in capistrano.

Enjoy!!!!!



About Ram Laxman Yadav
Ram Laxman Yadav

Senior Software Engineering Professional | Tech Enthusiast | Mentor | Payments | Hospitality | E-Commerce, based in NCR, India

Email : info@ramlaxman.co.in

Website : https://ramlaxman.co.in