在适用于环境的方面存在问题。我遵循的答案是:rake-aborted-dont-know-how-to-build-task,但最终得到...
bash-4.4$ rake -T
rake jenkins # Do stuff..
rake jenkins:build[params] # TODO
rake jenkins:logs # TODO
bash-4.4$ rake jenkins:logs
rake aborted!
Don't know how to build task 'environment'
Tasks: TOP => jenkins:logs
(See full trace by running task with --trace)
bash-4.4$
代码在这里,应该可以正常工作...
require 'rake'
namespace :jenkins do
desc "TODO"
task :build, [:params] => :environment do | task, args |
puts "[info] #{params}"
end
desc "TODO"
task :logs => :environment do
puts "[info] Logs"
end
task :all => [:build, :logs]
end
desc "Do stuff..."
task :jenkins => 'jenkins:all'
版本信息(OSX)
bash-4.4$ which rake
rake is /usr/bin/rake
bash-4.4$ rake --version
以及完整的堆栈跟踪
bash-4.4$ rake jenkins:logs --trace
** Invoke jenkins:logs (first_time)
rake aborted!
Don't know how to build task 'environment'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task_manager.rb:62:in `[]'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:57:in `lookup_prerequisite'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:53:in `block in prerequisite_tasks'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:53:in `map'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:53:in `prerequisite_tasks'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/Library/Ruby/Gems/2.3.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/usr/bin/rake:22:in `load'
/usr/bin/rake:22:in `<main>'
Tasks: TOP => jenkins:logs
rake, version 10.4.2
我认为我不需要空的任务定义,例如...
require 'rake'
task :environment do end
namespace :jenkins do
desc "TODO"
task :build, [:params] => :environment do | task, args |
puts "[info] #{params}"
end
desc "TODO"
task :logs => :environment do
puts "[info] Logs"
end
task :all => [:build, :logs]
end
desc "Do stuff..."
task :jenkins => 'jenkins:all'
有悖常理