Jenkins使用错误版本的Ruby(rvm) [英] Jenkins using wrong version of Ruby(rvm)

查看:364
本文介绍了Jenkins使用错误版本的Ruby(rvm)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有下一种情况:

  • 使用詹金斯
  • 已安装具有不同ruby版本(2+)的rvm
  • 已安装 rvm插件

使用ruby版本ruby-2.3.0@global

现在关于问题.在每次詹金斯工作开始后,我可以看到下一个输出:

Now about problem. After each starting of jenkins job I can see next output:

Capturing environment variables produced by 'rvm use ruby-2.3.0@global'
$ bash -c export
[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create ruby-2.3.0@global && export > rvm.env"
Using /usr/local/rvm/gems/ruby-2.3.0 with gemset global
...

似乎一切都应该正常. 但实际上jenkins使用ruby-2.2.0,因为在日志下面,我发现了这一点:

And seems everything should works ok. But in fact jenkins use ruby-2.2.0 because below in log I found this:

+++ __path_to_ruby=/usr/local/rvm/rubies/ruby-2.2.0/bin/ruby
+++ [[ -z /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby ]]
+++ [[ /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby != \/\u\s\r\/\l\o\c\a\l\/\r\v\m* ]]
+++ [[ /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby == \/\u\s\r\/\l\o\c\a\l\/\r\v\m\/\b\i\n\/\r\u\b\y ]]
+++ [[ /usr/local/rvm/rubies/ruby-2.2.0/bin/ruby == \/\u\s\r\/\l\o\c\a\l\/\r\v\m* ]]
+++ [[ -z /usr/local/rvm/gems/ruby-2.2.0 ]]
+++ [[ -z /usr/local/rvm/gems/ruby-2.2.0:/usr/local/rvm/gems/ruby-2.2.0@global ]]
...

下一个来自这里的问题:

And next problem which stems from here:

Gem::InstallError: activesupport requires Ruby version >= 2.2.2.

如果我在执行外壳"区域中键入ruby -v命令-那么在日志中我会看到

Also if I type ruby -v command in "Execute shell" area - then in log I see this

+ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]

我还尝试直接在执行外壳"中启动命令rvm use ruby-2.3.0.

I also tried to start command rvm use ruby-2.3.0 directly in "Execute shell".

我也将此添加到了/var/lib/jenkis/.bashrc:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

并尝试将$HOME/.rvm更改为/usr/local/rvm

但是每次结果都是一样的.詹金斯不使用ruby-2.3.0

But everytime result the same. Jenkins does not use ruby-2.3.0

请帮助我弄清楚我错过了什么?

Please help me figure out what did I miss?

推荐答案

我也遇到了这个问题.原来,如果您以root身份安装rvm,则会出现问题.我们必须完全卸载rvm并以jenkins用户身份重新安装,之后该插件才能正确加载rubies.

I ran into this problem too. It turned out that there is an issue if you install rvm as root. We had to fully uninstall rvm and reinstall as the jenkins user, after which the plugin correctly loaded rubies.

您可以通过列出Jenkins的$ HOME变量指向的目录的内容来检测此问题.如果没有.rvm目录,则可能需要重新安装.

You can detect this problem by listing the contents of the directory pointed by Jenkins's $HOME variable. If there is no .rvm directory then you may need to reinstall.

这篇关于Jenkins使用错误版本的Ruby(rvm)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆