Skip to content

Instantly share code, notes, and snippets.

@joshukraine
Created April 24, 2015 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshukraine/bb40168de26d0d99a917 to your computer and use it in GitHub Desktop.
Save joshukraine/bb40168de26d0d99a917 to your computer and use it in GitHub Desktop.
# lib/capistrano/tasks/remote_rake_task.rake
#
# This task allows you to run rake tasks on the remote server using Capistrano.
# The rake task itself is passed in as an argument.
# Example:
# bin/cap staging "task:invoke[app:setup]"
#
# References:
# http://www.jetthoughts.com/blog/magic/2013/09/26/capistrano-3-passing-parameters-to-your-task.html
# http://stackoverflow.com/questions/23828950/how-to-run-custom-rake-task-via-capistrano-3
namespace :task do
desc 'Execute a specific rake task'
task :invoke, :command do |task, args|
on roles(:app) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, args[:command]
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment