我在我的 Jenkins 工作中使用了几个 Rake 步骤(通过 Rake 插件),但它声称无法找到 Rake:
+ bundle update
.................................
Using rake (0.9.2.2)
.................................
[workspace] $ rake db:drop
FATAL: rake execution failed
java.io.IOException: Cannot run program "rake" (in directory "/var/lib/jenkins/jobs/myproject/workspace"): java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:475)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:709)
at hudson.Launcher$ProcStarter.start(Launcher.java:338)
at hudson.Launcher$ProcStarter.join(Launcher.java:345)
at hudson.plugins.rake.Rake.perform(Rake.java:141)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:717)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1502)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:236)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:468)
... 15 more
Build step 'Invoke Rake' marked build as failure
Finished: FAILURE
如果我在 Jenkins 的配置中手动指定 Ruby 路径:
[workspace] $ rake db:drop
[31mERROR: Gem rake is not installed, run `gem install rake` first.(B[m
Build step 'Invoke Rake' marked build as failure
Finished: FAILURE
如果我在 Jenkins 中将 rake 作为普通 shell 命令执行,没有 Rake 插件:
+ rake db:drop
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
当我执行“bundle exec rake db:drop”时,同样发生了两次。
在作业中暂时包括两行:
rvm pkg install libyaml
rvm reinstall 1.9.3
没有帮助。(更新:这只是警告,不会影响任何事情,但很烦人)。
我在 Jenkins 之外的 ~/.rvm 目录中安装了另一个 RVM + Ruby 包,它工作得很好。