capistrano v3.2中的错误任务排序

时间:2014-04-23 17:28:44

标签: ruby-on-rails ruby capistrano

我不理解capistrano中的任务排序。 (使用3.2版本)

更新的代码示例

test_ordering.cap文件包含:

namespace :test_ordering do

  desc 'Starting task'
  task :start_testing do
    puts 'This task must be in the middle'
  end

  desc 'First message'
  task :first_message do
    puts 'This task must fire first, before starting task'
  end

  desc 'Second message'
  task :second_message do
    puts 'This task must be the last'
  end

  before 'test_ordering:start_testing', 'test_ordering:first_message'
  after 'test_ordering:start_testing', 'test_ordering:second_message'
end

当我正在bundle exec cap staging test_ordering:start_testing时,它会返回:

ruby 2.0.0p451 (2014-02-24 revision 45167) [i686-linux]
This task must be in the middle
This task must fire first, before starting task
This task must be the last

“准备”任务之后为什么'之前'开火? 我的环境使用Ruby 2.0.0p451,Rails 4.0.4和Capistrano 3.2。

1 个答案:

答案 0 :(得分:0)

适合我:

Matt-Gibsons-iMac:captest matt$ cap -V
Capistrano Version: 3.2.1 (Rake Version: 10.1.0)
Matt-Gibsons-iMac:captest matt$ cap staging test_ordering:start_testing
This task must fire first, before starting task
This task must be in the middle
This task must be the last

我所做的只是cap init,将您的代码粘贴到/lib/capistrano/tasks/test_ordering.rake,然后运行。

你说你正在使用.cap文件 - latest Capistrano prefers .rake files,因此结合我的正确结果会让我觉得你可能会遇到旧版Capistrano中的错误。

看看最近的问题历史,我猜你正在打this bug, fixed in 3.2.1。升级到3.2.1,您的问题就会消失。