blob: fa7c0eadf792242fbbec279c49ba4e04a8df0e44 [file] [log] [blame]
Jakub Josef25c0ea52017-04-27 17:46:27 +02001package com.mirantis.mk
2
3/**
4 * Ruby functions
5 */
6
Jakub Josefad59b2f2017-04-28 16:08:40 +02007/**
8 * Ensures Ruby environment with given version (install it if necessary)
9 * @param rubyVersion target ruby version (optional, default 2.3.2)
10 */
11def ensureRubyEnv(rubyVersion="2.3.2"){
12 if(!fileExists("/var/lib/jenkins/.rbenv/versions/${rubyVersion}/bin/ruby")){
13 sh "rbenv install ${rubyVersion}";
14 }
15 sh "rbenv local ${rubyVersion};rbenv exec gem update --system"
Jakub Josef25c0ea52017-04-27 17:46:27 +020016}
Jakub Josefad59b2f2017-04-28 16:08:40 +020017
18/**
19 * Install kitchen tools
20 */
Jakub Josef25c0ea52017-04-27 17:46:27 +020021def installKitchen(){
22 sh """rbenv exec gem install bundler;
23 rbenv exec gem install test-kitchen"""
24}
25
Jakub Josefad59b2f2017-04-28 16:08:40 +020026/**
27 * Run kitchen tests in tests/integration
28 */
Jakub Josef25c0ea52017-04-27 17:46:27 +020029def runKitchenTests(){
30 runKitchenCommand("converge")
31 runKitchenCommand("verify -t tests/integration")
32}
33
Jakub Josefad59b2f2017-04-28 16:08:40 +020034/**
35 * Run kitchen command
36 * @param cmd kitchen command
37 */
Jakub Josef25c0ea52017-04-27 17:46:27 +020038def runKitchenCommand(cmd){
39 sh "rbenv exec bundler exec kitchen ${cmd}"
40}
41
42
43