Posted over 7 years ago. Visible to the public.

Dynamically skip Capistrano hooks

When you have a hook in your Capistrano file that dumps your remote database, you might not want it to dump each time you deploy (say, you're experimenting with staging and don't want ten dumps an hour). How to skip dump creation:

Capistrano 2

In your Capistrano file:

Copy
before 'deploy:update_code', 'db:dump' unless fetch(:skip_dump, false)

The second parameter of fetch sets a default value if skip_dump is not defined.

In your terminal:

Copy
cap staging deploy -S skip_dump=true

The -S must be a capital letter to set skip_dump before loading the recipes.

Capistrano 3

In your Capistrano file:

Copy
before 'deploy:updating', 'db:dump' unless ENV['SKIP_DUMP']

In your terminal:

Copy
SKIP_DUMP=true cap staging deploy

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Dominik Schöler
Last edit:
30 days ago
by Natalie Krehan
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more