The Plugin class is a simple set of conventions for defining Capistrano plugins.
This is to support the eventual migration of SCM logic out of Capistrano itself
and into separate gems as plugins.
It seems that enhancing a task using an `after` block will not have desired
effect if the new task shares the same name (excluding namespace) as the task
being enhanced. In other words, `after 'deploy:failed', :failed do ...` will
not work (the block will never be executed). This behavior was recently
introduced in 5fcf3da.
To fix the feature test using this code, I renamed the task to be a unique name.
The test now works as intended.
Also, I noticed the task defined in `fail.rake` was sometimes not working as
intended, because the `shared_path` did not exist on the VM's filesystem. This
meant that `touch` was failing. Corrected by issuing `mkdir -p` first.
With these changes, all feature tests now pass.
If an error is raised during a deploy, the task `deploy:failed` will be
triggered. Custom tasks can hook into this using `after`:
after 'deploy:failed', :send_for_help do
#
end
I've also taken the opportunity to provide a marginally more useful
error message before triggering the task.
By default, this 'deploy:failed' will only be triggered when running
`cap <stage> deploy` - to trigger after individual tasks use `set
:deploying, true`
This closes#708 and replaces
https://github.com/capistrano/capistrano/pull/720
The commit introduces a `remote_file` task, allowing the existence of a remote
file to be set as a prerequisite. These tasks can in turn depend on local
files if required. In this implementation, the fact that we're dealing with a
file in the shared path is assumed.
As as example, this task can be used to ensure that files to be linked exist
before running the `check:linked_files` task:
namespace :deploy do
namespace :check do
task :linked_files => 'config/newrelic.yml'
end
end
remote_file 'config/newrelic.yml' => '/tmp/newrelic.yml', roles: :app
file '/tmp/newrelic.yml' do |t|
sh "curl -o #{t.name} https://rpm.newrelic.com/accounts/xx/newrelic.yml"
end