Jenkins using wrong version of Ruby(rvm)

隐身守侯 提交于 2019-12-23 13:16:49

问题


Have next situation:

  • Using jenkins
  • Installed rvm with different ruby versions(2+)
  • Installed rvm plugin

Enabled option "Run the build in a RVM-managed environment" in "Build Environment" with ruby version 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
...

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.

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]

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

Also I added this into /var/lib/jenkis/.bashrc:

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

And tried to change $HOME/.rvm to /usr/local/rvm

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

Please help me figure out what did I miss?


回答1:


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.

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.



来源:https://stackoverflow.com/questions/41633776/jenkins-using-wrong-version-of-rubyrvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!