Skip to content

Plugin for managing Ruby within Jenkins pipelines

License

Notifications You must be signed in to change notification settings

BenWildeman/withruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages