Posted about 8 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
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
7 months 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