Reputation: 1703
A client has jenkins setup on a macOS machine. It's doing iOS builds and uses bundler to install some gems. One gem recently started requiring a dependency which in turn requires ruby >= 2.1
Installing jwt 2.1.0
Gem::InstallError: jwt requires Ruby version >= 2.1.
An error occurred while installing jwt (2.1.0), and Bundler cannot continue.
For one, I've installed rvm and ruby 2.1.0 on the macOS machine
osxbuildserver:~ jenkins$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin14.0]
and for the ssh login user it shows up fine. The issue is that even tough Jenkins runs under the same jenkins user
root 15102 1 15102 0 0 Ss ?? 0:00.04 sshd: jenkins [priv]
jenkins 15106 15102 15102 0 0 S ?? 0:00.03 sshd: jenkins@ttys000
it still uses the system ruby which is 2.0.0. In one of the builds I've added a shell script with ruby -v
[EnvInject] - Variables injected successfully.
[workspace] $ /bin/sh -xe /var/folders/6v/xlw3p2pn47d2jl_jghf25dn00000gr/T/hudson73325394438439334.sh
+ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
Calling
ssh jenkins@osxbuild "echo $PATH"
from my local machine, returns the incorrect path
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
but login in with the same user is fine
osxbuildserver:~ jenkins$ echo $PATH
/Users/jenkins/.rvm/gems/ruby-2.1.0/bin:/Users/jenkins/.rvm/gems/ruby-2.1.0@global/bin:/Users/jenkins/.rvm/rubies/ruby-2.1.0/bin.... etc
I've already tried the answer from here Jenkins using System Ruby - use rvm ruby? but it didn't help.
my .bash_profile contents
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export ANDROID_HOME=/Users/jenkins/Library/Android/sdk
export ANDROID_SDK=$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$JAVA_HOME
export TESSDATA_PREFIX=$HOME/tesseract-ocr
source ~/.profile
source $HOME/.rvm/scripts/rvm
Upvotes: 2
Views: 2517
Reputation: 261
I messed up with this problem for a few days, finally its working well, thanks to the inspiration from @BlackRainbow
What Exactly I Do:
- Used rbenv to manage my Ruby environment
- Open terminal and execute
echo $PATH
- Copy the result and paste to Jenkinsfile
- Re-try to build your pipeline
- Thats it, and its working well in my enviroment
Attachment:
Upvotes: 0
Reputation: 1904
The question is quite old but probably somebody will use my solution.
I copied everything that gave me echo $PATH
. Then I opened Jenkin's configuration and found "Global properties".
I added PATH and as a value I added value from terminal.
Upvotes: 6