Provides simple commands for blocking Capistrano deploys.
Sometimes (hopefully rarely) situations will arise where you need to prevent other developers from deploying the application. While you can usually send out a warning via chat or email, it might not get seen in time. It would be useful to be able to display a warning before they actually try to deploy.
The capistrano-deploy-block
plugin aims to make this easy by defining two
tasks for blocking (deploy:block
) and unblocking (deploy:unblock
) deploys
for your application.
- Ruby 1.9.3+
- Capistrano 3
-
Add the following to your application's
Gemfile
:gem 'capistrano-deploy-block'
...and then execute
bundle install
. -
Add the following to your application's
Capfile
:require 'capistrano/deploy_block'
-
Specify which server you want to use to store whether or not deploys are blocked. A simple choice is to pick one of your application servers. Note that this must be one server, not a collection.
# config/deploy.rb set :deploy_block_host, -> { primary(:app) }
To block deploys, simply execute:
cap <stage> deploy:block
To unblock deploys, execute:
cap <stage> deploy:unblock
After blocking a deploy, any engineer who attempts to deploy will get an error message like the following:
johndoe blocked deploys at 2014-10-16 11:46:13 -0700
Anyone can unblock a deploy. The goal is not to have one person be in control of deploys, but to warn others that deploying is currently unsafe and that they should coordinate.
The following options are configurable.
# Message displayed to users who attempt to deploy when deploys are blocked
set :deploy_block_message, -> { "#{local_user} blocked deploys at #{Time.now}" }
# File created on the deploy_block_host to signal that a deploy is blocked
set :deploy_block_file, -> { File.join(shared_path, 'deploy-block') }
# The host where the deploy block file is stored
set :deploy_block_host, -> { primary(:app) }
This project is released under the MIT license