gpt4 book ai didi

ruby - 尽管 RVM 插件 Jenkins 使用了错误的 ruby​​ 版本

转载 作者:行者123 更新时间:2023-12-04 13:49:37 24 4
gpt4 key购买 nike

Jenkins 在 ubuntu 机器上运行。它有一个特殊的用户 jenkins 用于执行作业。
RVM 已安装并在服务器上的 ssh shell 中,以 jenkins 用户身份登录,一切正常。(如果我将 RVM 设置为使用 ruby​​ 1.9.3 ruby -v 返回 1.9.3 作为版本)
我为 Jenkins 使用 RVM 插件并将其设置为使用 1.9.3

Jenkins 为 RVM 输出: 捕获由“rvm use 1.9.3”产生的环境变量 $ bash -c 导出
$ bash -c "test -f ~/.rvm/scripts/rvm"
$ bash -c "test -f/usr/local/rvm/scripts/rvm"
[工作区] $ bash -c "source/usr/local/rvm/scripts/rvm && rvm use --install --create 1.9.3 && export > rvm.env"
使用/usr/local/rvm/gems/ruby-1.9.3-p0


但是,如果我以后想执行我的脚本,它会使用 ruby​​ 版本 1.8.7。

ruby 版本和环境的输出:

  + which ruby  
/usr/bin/ruby
+ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
+ rvm info

ruby-1.9.3-p0:

system:
uname: "Linux h1332957.stratoserver.net 2.6.32-042stab078.27 #1 SMP Mon Jul 1 20:48:07 MSK 2013 i686 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2010-01-10"
platform: "i486-linux"
patchlevel: "2010-01-10 patchlevel 249"
full_version: "ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]"
homes:
gem: "/usr/local/rvm/gems/ruby-1.9.3-p0"
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
binaries:
ruby: "/usr/bin/ruby"
irb: "/usr/bin/irb"
gem: "/usr/bin/gem"
rake: "/usr/bin/rake"
environment:
PATH: "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin:/usr/local/rvm/bin"
GEM_HOME: "/usr/local/rvm/gems/ruby-1.9.3-p0"
GEM_PATH: "/usr/local/rvm/gems/ruby-1.9.3-p0:/usr/local/rvm/gems/ruby-1.9.3-p0@global"
MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
IRBRC: "/usr/local/rvm/rubies/ruby-1.9.3-p0/.irbrc"
RUBYOPT: ""
gemset: ""

问题:
如何让 Jenkins 改用 ruby​​ 版本 1.9.3?

最佳答案

我通过采购 rvm 解决了这个问题。
我将脚本更新为如下所示:

 #!/bin/bash
source "/usr/local/rvm/scripts/rvm"
rvm use 1.9.3
rvm info

现在 rvm info 的输出是正确的。
最重要的是第一行和第二行。


rvm info 输出:

 ruby-1.9.3-p0:

system:
uname: "Linux h1332957.stratoserver.net 2.6.32-042stab078.27 #1 SMP Mon Jul 1 20:48:07 MSK 2013 i686 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)"
zsh: " => not installed"

rvm:
version: "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"

ruby:
interpreter: "ruby"
version: "1.9.3p0"
date: "2011-10-30"
platform: "i686-linux"
patchlevel: "2011-10-30 revision 33570"
full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]"

homes:
gem: "/usr/local/rvm/gems/ruby-1.9.3-p0"
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p0"

binaries:
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby"
irb: "/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/irb"
gem: "/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/gem"
rake: "/usr/local/rvm/gems/ruby-1.9.3-p0/bin/rake"

environment:
PATH: "/usr/local/rvm/gems/ruby-1.9.3-p0/bin:/usr/local/rvm/gems/ruby-1.9.3-p0@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p0/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
GEM_HOME: "/usr/local/rvm/gems/ruby-1.9.3-p0"
GEM_PATH: "/usr/local/rvm/gems/ruby-1.9.3-p0:/usr/local/rvm/gems/ruby-1.9.3-p0@global"
MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
IRBRC: "/usr/local/rvm/rubies/ruby-1.9.3-p0/.irbrc"
RUBYOPT: ""
gemset: ""

关于ruby - 尽管 RVM 插件 Jenkins 使用了错误的 ruby​​ 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23616697/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com