【发布时间】:2014-05-30 00:23:54
【问题描述】:
我有一个静态页面,我想使用 gulp 在本地编译。我将在本地 shell 中运行的命令,从包含 gulp 和 gulpfile 的目录(在本例中由 compile_path 设置)将是“$> gulp build”。
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'appname'
set :repo_url, 'git@bitbucket.org/appname.git'
set :compile_path, '/Users/nico/DevOps/repo/appname'
# Default branch is :master
set :branch, 'cap3'
namespace :deploy do
after :started, :notify do
desc 'Run gulp to compile the static site'
task :gulp_build do
run_locally do
execute "#{fetch(:compile_path)}/gulp", " build"
end
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
基本上,我想要实现的是本地预编译,这样我的部署只需将本地编译的文件发送到部署位置。当我执行“bundle exec cap staging deploy:gulp_build”时,我得到:
上限中止!
不知道如何构建任务'deploy:gulp_build'
/Users/nico/.rvm/gems/ruby-1.9.3-p545/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in run'
/Users/nico/.rvm/gems/ruby-1.9.3-p545/gems/capistrano-3.1.0/bin/cap:3:in'
/Users/nico/.rvm/gems/ruby-1.9.3-p545/bin/cap:23:in load'
/Users/nico/.rvm/gems/ruby-1.9.3-p545/bin/cap:23:in'
/Users/nico/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in eval'
/Users/nico/.rvm/gems/ruby-1.9.3-p545/bin/ruby_executable_hooks:15:in'
(通过使用 --trace 运行任务查看完整跟踪)
我意识到可能有更好的方法来部署它,但它是通过 capistrano 成功部署的 rails 应用程序的配套静态站点,我想对两者使用相同的部署方法。
【问题讨论】:
-
我能够通过在 /lib/capistrano/tasks/gulp_build.cap 中创建一个新任务来解决这个问题,将其放入“deploy”命名空间并从 deploy.rb 调用它:之前:部署,“部署:gulp_build”。当计时器到期时,我会回答我自己的问题。此外,编辑问题标题以更好地反映所做的工作。