jenkins无法运行程序“ruby”没有这样的文件或目录

8gsdolmq  于 2023-10-17  发布在  Jenkins
关注(0)|答案(2)|浏览(156)

我从Jenkins和它的失败不断运行这个工作.

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/deploy-mapreduce/workspace
Capturing environment variables produced by 'rvm use ruby-1.9.3-p484'
$ bash -c export
$ bash -c "test -f ~/.rvm/scripts/rvm"
$ bash -c "test -f /usr/local/rvm/scripts/rvm"
[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create ruby-1.9.3-p484 && export > rvm.env"
Using /usr/local/rvm/gems/ruby-1.9.3-p484
[workspace] $ ruby -v /tmp/hudson4593249725887441871.rb
FATAL: command execution failed
java.io.IOException: Cannot run program "ruby" (in directory "/var/lib/jenkins/jobs/deploy-mapreduce/workspace"): java.io.IOException: error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
    at hudson.Launcher$ProcStarter.start(Launcher.java:353)
    at hudson.Launcher$ProcStarter.join(Launcher.java:360)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:94)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:63)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:785)
    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:566)
    at hudson.model.Run.execute(Run.java:1677)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:231)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
    at java.lang.ProcessImpl.start(ProcessImpl.java:65)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
    ... 16 more

然而,我可以从shell运行一个测试ruby文件,它工作正常

[root@jenkins01 etc]# su -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create ruby-1.9.3-p484 && export > rvm.env ; ruby -v /tmp/test.rb" -s /bin/bash jenkins
Using /usr/local/rvm/gems/ruby-1.9.3-p484
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
hello

我认为它缺少这个文件.”/tmp/hudson4593249725887441871.rb”,但作为用户“Jenkins”,我可以在/tmp目录下创建文件罚款.
你知道问题会在哪里吗?

kmbjn2e3

kmbjn2e31#

堆栈跟踪基本上意味着Jenkins启动的构建过程无法找到Ruby可执行文件。
如果可以的话,使用RVM Jenkins plugin。它:
在您选择的RVM托管环境的上下文中执行整个构建(从SCM checkout 到构建后操作)(而不是执行“source ~/.rvm/scripts/rvm && rvm foo@bar”,这只会影响您当前的shell)
如果您指定的Ruby/gemset在构建运行的从服务器上不存在,它将被自动安装和创建(通过rvm_install_on_use_flag)

s4n0splo

s4n0splo2#

很可能,Jenkins找不到Ruby路径,这就是为什么它给出了一个文件找不到异常。请尝试以下步骤:
1.执行“which ruby”-这将给予完整的ruby路径
1.在你的程序中替换这个路径,这样就不用写ruby了,给予完整的路径。

相关问题