From 69af2e310f287a949dbbeb4ca8bbb851a0a739b3 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 6 Jul 2016 17:01:35 -0700 Subject: [PATCH] Simplify Pipeline --- Jenkinsfile | 53 ++++------------------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b683ed5..40ec3cd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,22 +10,11 @@ node { // Checkout checkout scm - // Use a particular version of ruby (configured by rvm) to run build - withRuby (version: '2.1.9', - sh: ''' - # install required bundles - bundle install || exit 1 + // install required bundles + sh 'bundle install' - # compile native components - bundle exec rake compile || exit 1 - - # build the package - bundle exec rake build || exit 1 - - # run tests and coverage - bundle exec rake spec || exit 1 - ''' - ) + // build and run tests with coverage + sh 'bundle exec rake build spec' // Archive the built artifacts archive (includes: 'pkg/*.gem') @@ -40,39 +29,5 @@ node { reportFiles: 'index.html', reportName: "RCov Report" ]) -} - -// Helper to run shell with specific ruby version configured. -// Rvm configuration is a bit involved and can go sideways easily -def withRuby (rubyVersion, sh) { - // Rvm wants the shell it runs in to be a login shell - def shellScript = """#!/bin/bash --login - # Ensure rvm is configured - rvm current || exit 1 - - # Rvm also wants to be run from a function, so pull it in - [[ -s "\$HOME/.rvm/scripts/rvm" ]] && source "\$HOME/.rvm/scripts/rvm" - - # Ensure the requested version of ruby is installed - rvm install ${rubyVersion} || exit 1 - - # Use the requested version of ruby - rvm use ${rubyVersion} || exit 1 - rvm current && rvm info || exit 1 - - # Fail if the requested version of ruby is not active when we're done - [[ "\$(rvm current)" == *"${rubyVersion}"* ]] || { - echo Failed to set ruby to version ${rubyVersion}! - exit 1 - } - - # ensure bundle gem is installed for this version of ruby - gem install bundle - - # run the commands that were passed - ${sh} - """ - - sh shellScript }