Fix ensureRuby method to be able to switch versions
- Remove 'git clone' block, because it's not needed
- Always install to Workspace and not global file path
Related: PROD-26476 (PROD:26476)
Change-Id: I623f9ccf954f3de3d0978671058f953e51167758
diff --git a/src/com/mirantis/mk/Ruby.groovy b/src/com/mirantis/mk/Ruby.groovy
index 32b595e..7802a11 100644
--- a/src/com/mirantis/mk/Ruby.groovy
+++ b/src/com/mirantis/mk/Ruby.groovy
@@ -9,20 +9,13 @@
* @param rubyVersion target ruby version (optional, default 2.2.3)
*/
def ensureRubyEnv(rubyVersion="2.4.1"){
- def ruby_build_root = "~/.rbenv/plugins/ruby-build"
+ def ruby_build_root = "${env.WORKSPACE}/.rbenv/plugins/ruby-build"
if (!fileExists("/var/lib/jenkins/.rbenv/versions/${rubyVersion}/bin/ruby")){
//XXX: patch ruby-build because debian package is quite old
- // Check if git repo exists
- if (!fileExists("${ruby_build_root}/.git")) {
- sh "git clone https://github.com/rbenv/ruby-build.git ${ruby_build_root}"
- } else {
- // Ensure the repo is up-to-date
- sh "cd ${ruby_build_root}"
- sh "git pull"
- }
- sh "rbenv install ${rubyVersion}";
+ sh "rbenv install ${rubyVersion} -sv";
}
sh "rbenv local ${rubyVersion};rbenv exec gem update --system"
+ sh "rm -rf ${ruby_build_root}"
}
/**