-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test using rbenv for foreman-installer tests
- Loading branch information
Showing
5 changed files
with
89 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
def bundleInstall(version, gemfile=null) { | ||
command = "bundle install" | ||
|
||
if (gemfile) { | ||
command = "${command} --gemfile=${gemfile}" | ||
} | ||
|
||
withRuby(version, "bundle config set path ~/.rubygems") | ||
withRuby(version, command) | ||
} | ||
|
||
def bundleExec(version, command, gemfile=null) { | ||
command = "bundle exec ${command}" | ||
|
||
if (gemfile) { | ||
command = "BUNDLE_GEMFILE=${gemfile} ${command}" | ||
} | ||
|
||
withRuby(version, command) | ||
} | ||
|
||
def withRuby(version, command) { | ||
echo command.toString() | ||
|
||
sh """ | ||
export PATH="\$HOME/.rbenv/shims:\$PATH" | ||
export RBENV_VERSION=${version} | ||
${command} | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
def ruby = '2.7.6' | ||
|
||
pipeline { | ||
agent { label 'el8' } | ||
options { | ||
timeout(time: 1, unit: 'HOURS') | ||
ansiColor('xterm') | ||
} | ||
|
||
stages { | ||
stage('Setup Git Repos') { | ||
steps { | ||
git url: 'https://github.com/theforeman/foreman-installer', branch: 'develop' | ||
sh "cp Gemfile Gemfile.${ruby}" | ||
} | ||
} | ||
stage("bundle-install") { | ||
steps { | ||
bundleInstall(ruby, "Gemfile.${ruby}") | ||
} | ||
} | ||
stage('Run Rubocop') { | ||
steps { | ||
bundleExec(ruby, "rake rubocop TESTOPTS='-v' --trace", "Gemfile.${ruby}") | ||
} | ||
} | ||
stage('Run Tests') { | ||
steps { | ||
bundleExec(ruby, "rake spec TESTOPTS='-v' --trace", "Gemfile.${ruby}") | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
deleteDir() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- job: | ||
name: simple-ruby-test | ||
project-type: pipeline | ||
sandbox: true | ||
dsl: | ||
!include-raw: | ||
- pipelines/lib/rbenv.groovy | ||
- pipelines/test/simple-ruby.groovy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters