我有一个名为at_deployment:shops_assets_compile
每次调用cap部署时是否可以调用此任务?它需要适用于生产和暂存,而无需向cap #{env} deploy
添加新的命令行参数。
编辑:将以下内容添加到capistrano中,但似乎没有执行:
task :special_assets,:roles => :app do
run "cd #{current_path}; RAILS_ENV=#{rails_env} bundle exec rake at_deployment:shops_assets_compile"
end
Ful deploy.rb:
####Added for multiple environnements
set :stages, %w(prodtest production)
set :default_stage, "prodtest"
require "capistrano/ext/multistage"
require "rvm/capistrano"
require "bundler/capistrano"
load "deploy/assets"
# require 'capistrano/rails'
set :repodomain,"***"
set :user,"***"
set :application, "***"
set :repository,"#{user}@#{repodomain}:/srv/outils/repos/#{application}"
set :scm, 'git'
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
set :ssh_options, {:forward_agent => true}
set :use_sudo, false
default_run_options[:pty] = true
set :keep_releases, 5
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:key => "value",
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
task :special_assets,:roles => :app do
run "cd #{current_path}; RAILS_ENV= #{rails_env}bundle exec rake at_deployment:shops_assets_compile"
end
after "deploy:restart", "deploy:cleanup"