diff --git a/theforeman.org/pipelines/deploy/website.groovy b/theforeman.org/pipelines/deploy/website.groovy index 6311a456..b3791833 100644 --- a/theforeman.org/pipelines/deploy/website.groovy +++ b/theforeman.org/pipelines/deploy/website.groovy @@ -9,7 +9,7 @@ pipeline { } environment { - ruby_version = '2.7' + ruby = '2.7.6' // Sync to the pivot-point on the web node target_path = 'website@web01.osuosl.theforeman.org:rsync_cache/' rsync_log = 'deploy-website.log' @@ -21,13 +21,8 @@ pipeline { git url: 'https://github.com/theforeman/theforeman.org', branch: 'gh-pages' script { - try { - configureRVM(ruby_version) - withRVM(['bundle install --jobs=5 --retry=5'], ruby_version) - withRVM(['bundle exec jekyll build'], ruby_version) - } finally { - cleanupRVM(ruby_version) - } + bundleInstall(ruby) + bundleExec(ruby, "jekyll build") } sshagent(['deploy-website']) { diff --git a/theforeman.org/pipelines/lib/foreman.groovy b/theforeman.org/pipelines/lib/foreman.groovy index 56c597f1..7f52a03d 100644 --- a/theforeman.org/pipelines/lib/foreman.groovy +++ b/theforeman.org/pipelines/lib/foreman.groovy @@ -14,27 +14,19 @@ def addSettings(settings) { sh "cp config/settings.yaml.example config/settings.yaml" } -def configureDatabase(ruby, name = '') { - withRVM(['bundle install --without=development --jobs=5 --retry=5'], ruby, name) +def configureDatabase(ruby) { + bundleInstall(ruby, '--without=development') archiveArtifacts(artifacts: 'Gemfile.lock') - withRVM(['bundle exec rake db:drop >/dev/null 2>/dev/null || true'], ruby, name) - withRVM(['bundle exec rake db:create --trace'], ruby, name) - withRVM(['RAILS_ENV=production bundle exec rake db:create --trace'], ruby, name) - withRVM(['bundle exec rake db:migrate --trace'], ruby, name) + bundleExec(ruby, 'rake db:drop >/dev/null 2>/dev/null || true') + bundleExec(ruby, 'rake db:create --trace') + bundleExec(ruby, 'rake db:create --trace RAILS_ENV=production') + bundleExec(ruby, 'rake db:migrate --trace') } -def cleanup(ruby, name = '') { - try { - - withRVM(['bundle exec rake db:drop RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true'], ruby, name) - withRVM(['bundle exec rake db:drop RAILS_ENV=test DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true'], ruby, name) - withRVM(['bundle exec rake db:drop RAILS_ENV=development DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true'], ruby, name) - - } finally { - - cleanupRVM(ruby, name) - - } +def cleanup(ruby) { + bundleExec(ruby, 'rake db:drop RAILS_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true') + bundleExec(ruby, 'rake db:drop RAILS_ENV=test DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true') + bundleExec(ruby, 'rake db:drop RAILS_ENV=development DISABLE_DATABASE_ENVIRONMENT_CHECK=true >/dev/null 2>/dev/null || true') } def postgresqlTemplate(id) { @@ -68,7 +60,7 @@ production: """ } -def filter_package_json(ruby, gemset = '') { +def filter_package_json(ruby) { if (env.NODE_LABELS.contains('el8')) { python = 'python3.11' } else { @@ -77,7 +69,7 @@ def filter_package_json(ruby, gemset = '') { sh "${python} script/filter-package-json.py" - withRVM(["bundle exec ruby script/plugin_webpack_directories.rb > plugin_webpack.json"], ruby, gemset) + bundleExec(ruby, "ruby script/plugin_webpack_directories.rb > plugin_webpack.json") def plugin_webpack = readJSON file: 'plugin_webpack.json' plugin_webpack['plugins'].each { plugin, config -> sh "${python} script/filter-package-json.py --package-json ${config['root']}/package.json" diff --git a/theforeman.org/pipelines/lib/nightly_packaging.groovy b/theforeman.org/pipelines/lib/nightly_packaging.groovy index 40f4169b..87f7b962 100644 --- a/theforeman.org/pipelines/lib/nightly_packaging.groovy +++ b/theforeman.org/pipelines/lib/nightly_packaging.groovy @@ -1,28 +1,23 @@ def generate_sourcefiles(args) { def sourcefile_paths = [] def project_name = args.project_name - def ruby_version = args.ruby_version ?: '2.7' + def ruby_version = args.ruby_version ?: '2.7.6' def source_type = args.source_type dir(project_name) { echo source_type if (source_type == 'gem') { - withRVM(["gem build *.gemspec"], ruby_version) + withRuby(ruby_version, "gem build *.gemspec") sourcefiles = list_files('./').findAll { "${it}".endsWith('.gem') } archiveArtifacts(artifacts: sourcefiles.join(',')) sourcefile_paths = sourcefiles.collect { "${pwd()}/${it}" } } else { - try { - configureRVM(ruby_version) - withRVM(["bundle install --jobs 5 --retry 5"], ruby_version) - withRVM(["bundle exec rake pkg:generate_source"], ruby_version) - archiveArtifacts(artifacts: 'pkg/*') - sourcefile_paths = list_files('pkg/').collect { - "${pwd()}/pkg/${it}" - } - } finally { - cleanupRVM(ruby_version) + bundleInstall(ruby_version) + bundleExec(ruby_version, "rake pkg:generate_source") + archiveArtifacts(artifacts: 'pkg/*') + sourcefile_paths = list_files('pkg/').collect { + "${pwd()}/pkg/${it}" } } } diff --git a/theforeman.org/pipelines/lib/rbenv.groovy b/theforeman.org/pipelines/lib/rbenv.groovy index b6ffc7f4..986fe027 100644 --- a/theforeman.org/pipelines/lib/rbenv.groovy +++ b/theforeman.org/pipelines/lib/rbenv.groovy @@ -1,8 +1,8 @@ -def bundleInstall(version, gemfile=null) { - command = "bundle install" +def bundleInstall(version, options=null) { + command = "bundle install --jobs 5 --retry 5" - if (gemfile) { - command = "${command} --gemfile=${gemfile}" + if (options) { + command = "${command} ${options}" } withRuby(version, "bundle config set path ~/.rubygems") diff --git a/theforeman.org/pipelines/lib/rvm.groovy b/theforeman.org/pipelines/lib/rvm.groovy deleted file mode 100644 index 6df27d45..00000000 --- a/theforeman.org/pipelines/lib/rvm.groovy +++ /dev/null @@ -1,48 +0,0 @@ -def gemset(name = null) { - - def base_name = "${JOB_NAME}-${BUILD_NUMBER}" - - if (EXECUTOR_NUMBER != '0') { - base_name += '-' + EXECUTOR_NUMBER - } - - if (name) { - base_name += '-' + name.replace(".", "-") - } - - base_name -} - -def configureRVM(ruby, name = '', bundler_version = null) { - emptyGemset(ruby, name) - - if (ruby == '2.7') { - bundler_version = '2.4.22' - } - - if (bundler_version) { - withRVM(["gem install bundler -v '${bundler_version}' --no-document"], ruby, name) - } else { - withRVM(["gem install bundler --no-document"], ruby, name) - } -} - -def emptyGemset(ruby, name = '') { - withRVM(["rvm gemset empty ${gemset(name)} --force"], ruby, name) -} - -def cleanupRVM(ruby, name = '') { - withRVM(["rvm gemset delete ${gemset(name)} --force"], ruby, name) -} - -def withRVM(commands, ruby, name = '') { - - commands = commands.join("\n") - echo commands.toString() - - sh(script: """#!/bin/bash -l - set -e - rvm use ruby-${ruby}@${gemset(name)} --create - ${commands} - """, label: "${commands}") -} diff --git a/theforeman.org/pipelines/release/source/foreman-installer.groovy b/theforeman.org/pipelines/release/source/foreman-installer.groovy index 18113ea1..97cbd3bc 100644 --- a/theforeman.org/pipelines/release/source/foreman-installer.groovy +++ b/theforeman.org/pipelines/release/source/foreman-installer.groovy @@ -19,7 +19,7 @@ pipeline { } stage("test ruby 2.7 & puppet 7") { steps { - run_test(ruby: '2.7', puppet: '7') + run_test(ruby: '2.7.6', puppet: '7') } } stage('Build and Archive Source') { @@ -55,14 +55,8 @@ pipeline { def run_test(args) { def ruby = args.ruby def puppet = args.puppet - def gemset = "ruby-${ruby}-puppet-${puppet}" - try { - configureRVM(ruby, gemset) - withRVM(["PUPPET_VERSION='${puppet}' bundle install --without=development --jobs=5 --retry=5"], ruby, gemset) - archiveArtifacts(artifacts: 'Gemfile.lock') - withRVM(["PUPPET_VERSION='${puppet}' bundle exec rake spec"], ruby, gemset) - } finally { - cleanupRVM(ruby, gemset) - } + withRuby(ruby, "PUPPET_VERSION='${puppet}' bundle install --without=development --jobs=5 --retry=5") + archiveArtifacts(artifacts: 'Gemfile.lock') + withRuby(ruby, "PUPPET_VERSION='${puppet}' bundle exec rake spec") } diff --git a/theforeman.org/pipelines/release/source/foreman.groovy b/theforeman.org/pipelines/release/source/foreman.groovy index a5d3dbf3..a24ead68 100644 --- a/theforeman.org/pipelines/release/source/foreman.groovy +++ b/theforeman.org/pipelines/release/source/foreman.groovy @@ -14,8 +14,7 @@ pipeline { stage('ruby-2.7-postgres') { agent { label 'fast' } environment { - RUBY_VER = '2.7' - GEMSET = 'ruby2.7' + RUBY_VER = '2.7.6' } stages { stage("setup-2.7-postgres") { @@ -24,14 +23,13 @@ pipeline { script { archive_git_hash() } - configureRVM(env.RUBY_VER, env.GEMSET) - databaseFile(gemset(env.GEMSET)) - configureDatabase(env.RUBY_VER, env.GEMSET) + databaseFile("${env.JOB_NAME}-${env.BUILD_ID}") + configureDatabase(env.RUBY_VER) } } stage("unit-tests-2.7-postgres") { steps { - withRVM(['bundle exec rake jenkins:unit TESTOPTS="-v" --trace'], env.RUBY_VER, env.GEMSET) + bundleExec(env.RUBY_VER, 'rake jenkins:unit TESTOPTS="-v" --trace') } } } @@ -40,7 +38,7 @@ pipeline { junit(testResults: 'jenkins/reports/unit/*.xml') } cleanup { - cleanup(env.RUBY_VER, env.GEMSET) + cleanup(env.RUBY_VER) deleteDir() } } @@ -48,23 +46,21 @@ pipeline { stage('ruby-2.7-postgres-integrations') { agent { label 'fast' } environment { - RUBY_VER = '2.7' - GEMSET = 'ruby2.7-ui' + RUBY_VER = '2.7.6' } stages { stage("setup-2.7-postgres-ui") { steps { git url: git_url, branch: git_ref - configureRVM(env.RUBY_VER, env.GEMSET) - databaseFile(gemset(env.GEMSET)) - configureDatabase(env.RUBY_VER, env.GEMSET) - withRVM(['npm install --no-audit'], env.RUBY_VER, env.GEMSET) + databaseFile("${env.JOB_NAME}-${env.BUILD_ID}-ui") + configureDatabase(env.RUBY_VER) + withRuby(env.RUBY_VER, 'npm install --no-audit') archiveArtifacts(artifacts: 'package-lock.json') } } stage("integration-tests-2.7-postgres-ui") { steps { - withRVM(['bundle exec rake jenkins:integration TESTOPTS="-v" --trace'], env.RUBY_VER, env.GEMSET) + bundleExec(env.RUBY_VER, 'rake jenkins:integration TESTOPTS="-v" --trace') } } } @@ -73,7 +69,7 @@ pipeline { junit(testResults: 'jenkins/reports/unit/*.xml') } cleanup { - cleanup(env.RUBY_VER, env.GEMSET) + cleanup(env.RUBY_VER) deleteDir() } } @@ -81,29 +77,27 @@ pipeline { stage('ruby-2.7-nulldb-assets') { agent { label 'fast' } environment { - RUBY_VER = '2.7' - GEMSET = 'ruby2.7-assets' + RUBY_VER = '2.7.6' } stages { stage("setup-2.7-nulldb") { steps { git url: git_url, branch: git_ref - configureRVM(env.RUBY_VER, env.GEMSET) - withRVM(['bundle install --without=development --jobs=5 --retry=5'], env.RUBY_VER, env.GEMSET) + bundleInstall(env.RUBY_VER, '--without=development') sh "cp db/schema.rb.nulldb db/schema.rb" - filter_package_json(env.RUBY_VER, env.GEMSET) - withRVM(['npm install --no-audit'], env.RUBY_VER, env.GEMSET) + filter_package_json(env.RUBY_VER) + withRuby(env.RUBY_VER, 'npm install --no-audit') } } stage("assets-precompile-2.7-nulldb") { steps { - withRVM(['bundle exec rake assets:precompile RAILS_ENV=production DATABASE_URL=nulldb://nohost'], env.RUBY_VER, env.GEMSET) + bundleExec(env.RUBY_VER, 'rake assets:precompile RAILS_ENV=production DATABASE_URL=nulldb://nohost') } } } post { cleanup { - cleanup(env.RUBY_VER, env.GEMSET) + cleanup(env.RUBY_VER) deleteDir() } } diff --git a/theforeman.org/pipelines/release/source/hammer-cli-x.groovy b/theforeman.org/pipelines/release/source/hammer-cli-x.groovy index 05f32379..b124d652 100644 --- a/theforeman.org/pipelines/release/source/hammer-cli-x.groovy +++ b/theforeman.org/pipelines/release/source/hammer-cli-x.groovy @@ -20,7 +20,7 @@ pipeline { } stage("test-ruby-2.7") { steps { - run_test(ruby: '2.7') + run_test(ruby: '2.7.6') } } stage('Build and Archive Source') { @@ -63,16 +63,13 @@ def add_hammer_cli_git_repos(repos = []) { def run_test(args) { def ruby = args.ruby - def gemset = "ruby-${ruby}" try { - configureRVM(ruby, gemset) - withRVM(['bundle install --without=development --jobs=5 --retry=5'], ruby, gemset) + bundleInstall(ruby, '--without=development') archiveArtifacts(artifacts: 'Gemfile.lock') - withRVM(['bundle show'], ruby, gemset) - withRVM(['bundle exec rake ci:setup:minitest test TESTOPTS="-v"'], ruby, gemset) + withRuby(ruby, 'bundle show') + bundleExec(ruby, 'rake ci:setup:minitest test TESTOPTS="-v"') } finally { - cleanupRVM(ruby, gemset) junit(testResults: 'test/reports/*.xml') } } diff --git a/theforeman.org/pipelines/release/source/katello.groovy b/theforeman.org/pipelines/release/source/katello.groovy index 104829a1..daeb0d15 100644 --- a/theforeman.org/pipelines/release/source/katello.groovy +++ b/theforeman.org/pipelines/release/source/katello.groovy @@ -22,19 +22,12 @@ pipeline { } } } - stage("Setup RVM") { - steps { - - configureRVM(ruby) - - } - } stage('Configure Environment') { steps { dir('foreman') { addGem() - databaseFile(gemset()) + databaseFile("${env.JOB_NAME}-${env.BUILD_ID}") } } @@ -51,8 +44,8 @@ pipeline { stage('Install Foreman npm packages') { steps { dir('foreman') { - withRVM(["bundle exec npm install --package-lock-only --no-audit"], ruby) - withRVM(["bundle exec npm ci --no-audit"], ruby) + bundleExec(ruby, "npm install --package-lock-only --no-audit") + bundleExec(ruby, "npm ci --no-audit") } } } @@ -61,14 +54,14 @@ pipeline { stage('tests') { steps { dir('foreman') { - withRVM(['bundle exec rake jenkins:katello TESTOPTS="-v" --trace'], ruby) + bundleExec(ruby, 'rake jenkins:katello TESTOPTS="-v" --trace') } } } stage('rubocop') { steps { dir('foreman') { - withRVM(['bundle exec rake katello:rubocop TESTOPTS="-v" --trace'], ruby) + bundleExec(ruby, 'rake katello:rubocop TESTOPTS="-v" --trace') } } } @@ -102,7 +95,7 @@ pipeline { stage('assets-precompile') { steps { dir('foreman') { - withRVM(["bundle exec rake plugin:assets:precompile[${project_name}] RAILS_ENV=production --trace"], ruby) + bundleExec(ruby, "rake plugin:assets:precompile[${project_name}] RAILS_ENV=production --trace") } } } @@ -121,10 +114,10 @@ pipeline { dir('foreman') { - withRVM(['bundle exec rake db:drop RAILS_ENV=test >/dev/null 2>/dev/null || true'], ruby) - withRVM(['bundle exec rake db:create RAILS_ENV=test'], ruby) - withRVM(['bundle exec rake db:migrate RAILS_ENV=test'], ruby) - withRVM(['bundle exec rake db:seed RAILS_ENV=test'], ruby) + bundleExec(ruby, 'rake db:drop RAILS_ENV=test >/dev/null 2>/dev/null || true') + bundleExec(ruby, 'rake db:create RAILS_ENV=test') + bundleExec(ruby, 'rake db:migrate RAILS_ENV=test') + bundleExec(ruby, 'rake db:seed RAILS_ENV=test') } diff --git a/theforeman.org/pipelines/release/source/smart-proxy.groovy b/theforeman.org/pipelines/release/source/smart-proxy.groovy index 27df82bc..5746a11f 100644 --- a/theforeman.org/pipelines/release/source/smart-proxy.groovy +++ b/theforeman.org/pipelines/release/source/smart-proxy.groovy @@ -15,7 +15,7 @@ pipeline { axes { axis { name 'ruby' - values '2.7', '3.0', '3.1' + values '2.7.6', '3.0.4', '3.1.0' } } stages { @@ -77,16 +77,13 @@ pipeline { def run_test(args) { def ruby = args.ruby - def gemset = "ruby-${ruby}" try { - configureRVM(ruby, gemset) - withRVM(["cp config/settings.yml.example config/settings.yml"], ruby, gemset) - withRVM(["bundle install --without=development --jobs=5 --retry=5"], ruby, gemset) + sh "cp config/settings.yml.example config/settings.yml" + bundleInstall(ruby, "--without=development") archiveArtifacts(artifacts: 'Gemfile.lock') - withRVM(["bundle exec rake jenkins:unit --trace"], ruby, gemset) + bundleExec(ruby, "rake jenkins:unit --trace") } finally { - cleanupRVM(ruby, gemset) junit(testResults: 'jenkins/reports/unit/*.xml') } } diff --git a/theforeman.org/pipelines/release/tarballsRelease.groovy b/theforeman.org/pipelines/release/tarballsRelease.groovy index c141b55e..35732385 100644 --- a/theforeman.org/pipelines/release/tarballsRelease.groovy +++ b/theforeman.org/pipelines/release/tarballsRelease.groovy @@ -11,7 +11,7 @@ pipeline { environment { version = env.getProperty('version') major_version = env.getProperty('major_version') - ruby_ver = '2.7' + ruby_ver = '2.7.6' } stages { @@ -71,8 +71,6 @@ void build_tarball(project, version, ruby_ver) { changelog: false, poll: false - configureRVM(ruby_ver, project) - if (project == 'foreman') { sh "cat config/settings.yaml.example > config/settings.yaml" sh "cat config/database.yml.example > config/database.yml" @@ -81,20 +79,17 @@ void build_tarball(project, version, ruby_ver) { env.setProperty('DEBUG_RESOLVER', '1') if (fileExists("Gemfile")) { - withRVM(["bundle install --without=development --jobs=5 --retry=5"], ruby_ver, project) - rake = "bundle exec rake" + bundleInstall(ruby_ver, "--without=development") } if (project == 'foreman-installer') { - withRVM(["${rake} clean"], ruby_ver, project) + bundleExec(ruby_ver, "rake clean") } - withRVM(["${rake} pkg:generate_source"], ruby_ver, project) + bundleExec(ruby_ver, "rake pkg:generate_source") sshagent(['deploy-downloads']) { sh "rsync -v --ignore-existing pkg/* downloads@web01.osuosl.theforeman.org:${base_dir}/" } - - cleanupRVM(ruby_ver, project) } } diff --git a/theforeman.org/pipelines/test/smart-proxy.groovy b/theforeman.org/pipelines/test/smart-proxy.groovy index 77296c5a..6ffc1133 100644 --- a/theforeman.org/pipelines/test/smart-proxy.groovy +++ b/theforeman.org/pipelines/test/smart-proxy.groovy @@ -22,6 +22,7 @@ pipeline { agent any environment { BUNDLE_WITHOUT = 'bmc:development:dhcp_isc_inotify:dhcp_isc_kqueue:journald:krb5:libvirt:puppetca_token_whitelisting:realm_freeipa:windows' + RUBY_VERSION = '2.7.6' } stages { @@ -32,19 +33,14 @@ pipeline { } } } - stage('Setup RVM') { - steps { - configureRVM('2.7') - } - } stage('Install dependencies') { steps { - withRVM(['bundle install'], '2.7') + bundleInstall(RUBY_VERSION) } } stage('Run Rubocop') { steps { - withRVM(['bundle exec rubocop --format progress --out rubocop.log --format progress'], '2.7') + bundleExec(RUBY_VERSION, 'rubocop --format progress --out rubocop.log --format progress') } post { always { @@ -55,7 +51,6 @@ pipeline { } post { always { - cleanupRVM('2.7') deleteDir() } } @@ -67,7 +62,7 @@ pipeline { axes { axis { name 'ruby' - values '2.7', '3.0', '3.1' + values '2.7.6', '3.0.4', '3.1.0' } } environment { @@ -81,14 +76,9 @@ pipeline { } } } - stage('Setup RVM') { - steps { - configureRVM(ruby) - } - } stage('Install dependencies') { steps { - withRVM(['bundle install'], ruby) + bundleInstall(ruby) } } stage('Run Tests') { @@ -100,7 +90,7 @@ pipeline { MINITEST_REPORTERS_REPORTS_DIR = 'jenkins/reports/unit' } steps { - withRVM(['bundle exec rake jenkins:unit'], ruby) + bundleExec(ruby, 'rake jenkins:unit') } post { always { @@ -112,7 +102,6 @@ pipeline { post { always { archiveArtifacts artifacts: 'Gemfile.lock' - cleanupRVM(ruby) deleteDir() } } diff --git a/theforeman.org/pipelines/vars/katello-master-release.groovy b/theforeman.org/pipelines/vars/katello-master-release.groovy index bde17923..dbb5096c 100644 --- a/theforeman.org/pipelines/vars/katello-master-release.groovy +++ b/theforeman.org/pipelines/vars/katello-master-release.groovy @@ -5,4 +5,4 @@ def project_name = 'katello' def build_rpm = true def build_deb = false def source_type = 'gem' -def ruby = '2.7' +def ruby = '2.7.6'