Skip to content

Instantly share code, notes, and snippets.

@elenipapanik
Last active May 8, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elenipapanik/f01324272ac9b14dc4ae4d29c67ce0e1 to your computer and use it in GitHub Desktop.
Save elenipapanik/f01324272ac9b14dc4ae4d29c67ce0e1 to your computer and use it in GitHub Desktop.
def withRvm(version, cl) {
withRvm(version, "executor-${env.EXECUTOR_NUMBER}") {
cl()
}
}
def withRvm(version, gemset, cl) {
RVM_HOME="$env.HOME/.rvm"
paths = [
"$RVM_HOME/gems/$version@$gemset/bin",
"$RVM_HOME/gems/$version@global/bin",
"$RVM_HOME/rubies/$version/bin",
"$RVM_HOME/bin",
"${env.PATH}"
]
def path = paths.join(':')
withEnv(["RVM_HOME=${RVM_HOME}", "PATH=${env.PATH}:${RVM_HOME}"]) {
sh """#!/bin/bash -l
set +x; source $RVM_HOME/scripts/rvm; rvm use --create --install --binary $version@$gemset
"""
}
withEnv([
"PATH=$path",
"GEM_HOME=$RVM_HOME/gems/$version@$gemset",
"GEM_PATH=$RVM_HOME/gems/$version@$gemset:$RVM_HOME/gems/$version@global",
"MY_RUBY_HOME=$RVM_HOME/rubies/$version",
"IRBRC=$RVM_HOME/rubies/$version/.irbrc",
"RUBY_VERSION=$version"
]) {
sh 'gem install bundler'
cl()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment