BenWildeman / withruby

Plugin for managing Ruby within Jenkins pipelines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

withRuby Jenkins pipeline plugin

Plugin for managing Ruby within Jenkins pipelines that uses rbenv under the hood. Initial work created by pedrocesar-ti which can be found here: https://github.com/pedrocesar-ti/Xenv-jenkins-lib

Contents

Why use?

In some instances, it's not easy to manage ruby versions within Jenkins slaves, which is especially true with Mac slaves. As macOS comes with a system Ruby that's out of date, it's not easy to override this and have Jenkins pick it up. This plugin makes sure it uses rbenv when trying to use Ruby.

Installation

Can install with the two following ways:

Dynamic Import

You can dynamically import the library adding this snippet at the beginning of your Jenkinsfile:

library identifier: 'withruby-lib', 
        retriever: modernSCM([$class: 'GitSCMSource', 
        remote: 'https://github.com/BenWildeman/withruby.git'])

Global Shared Library

With the Global Shared Libraries, you can import this module inside your Jenkinsfile with the following:

@Library('withruby-lib') _

Usage

withRuby(version, method)

  • version - specify which Ruby version to use. Default 2.6.6
  • method - specify whether to keep or delete the Ruby version after use. Default keep
script {
    withRuby() {
        sh "ruby --version"
    }
}
script {
    withRuby("2.7.1", "delete") {
        sh "ruby --version"
    }
}

About

Plugin for managing Ruby within Jenkins pipelines

License:MIT License


Languages

Language:Groovy 100.0%