I don't understand task ordering in capistrano. (Using 3.2 version)
我不明白capistrano中的任务排序。 (使用3.2版本)
UPDATED example of code
更新的代码示例
test_ordering.cap
file contains:
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
When I'm doing bundle exec cap staging test_ordering:start_testing
it returns:
当我正在执行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
Why does 'before' fires after the 'prepare' task? My environment uses Ruby 2.0.0p451, Rails 4.0.4, and Capistrano 3.2.
为什么'之前'在'准备'任务之后开火?我的环境使用Ruby 2.0.0p451,Rails 4.0.4和Capistrano 3.2。
1 个解决方案
#1
0
Works for me:
适合我:
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
All I did was cap init
, paste your code into /lib/capistrano/tasks/test_ordering.rake
, and run.
我所做的就是封面初始化,将代码粘贴到/lib/capistrano/tasks/test_ordering.rake中,然后运行。
You say you're using a .cap
file -- the latest Capistrano prefers .rake files, so combined with my correct result would make me think that you might be running across a bug in an old version of Capistrano.
你说你正在使用.cap文件 - 最新的Capistrano更喜欢.rake文件,因此结合我正确的结果会让我觉得你可能会遇到旧版Capistrano中的错误。
Looking at the recent issues history, I'm guessing it's this bug, fixed in 3.2.1 that you're hitting. Upgrade to 3.2.1 and your problem should disappear.
看看最近的问题历史,我猜这是你在打3.2.1中修复的这个错误。升级到3.2.1,你的问题就会消失。
#1
0
Works for me:
适合我:
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
All I did was cap init
, paste your code into /lib/capistrano/tasks/test_ordering.rake
, and run.
我所做的就是封面初始化,将代码粘贴到/lib/capistrano/tasks/test_ordering.rake中,然后运行。
You say you're using a .cap
file -- the latest Capistrano prefers .rake files, so combined with my correct result would make me think that you might be running across a bug in an old version of Capistrano.
你说你正在使用.cap文件 - 最新的Capistrano更喜欢.rake文件,因此结合我正确的结果会让我觉得你可能会遇到旧版Capistrano中的错误。
Looking at the recent issues history, I'm guessing it's this bug, fixed in 3.2.1 that you're hitting. Upgrade to 3.2.1 and your problem should disappear.
看看最近的问题历史,我猜这是你在打3.2.1中修复的这个错误。升级到3.2.1,你的问题就会消失。