From 36c372c20a312d6cdfd01904b3771f1f21b1e9ae Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Thu, 10 Aug 2023 20:50:30 -0400 Subject: [PATCH] Add packaging release job for Copr --- .../foreman_packaging_rpm_copr_release.groovy | 88 +++++++++++++++++++ .../foreman-packaging-rpm-release.yaml | 28 ++++++ 2 files changed, 116 insertions(+) create mode 100644 theforeman.org/pipelines/release/foreman_packaging_rpm_copr_release.groovy diff --git a/theforeman.org/pipelines/release/foreman_packaging_rpm_copr_release.groovy b/theforeman.org/pipelines/release/foreman_packaging_rpm_copr_release.groovy new file mode 100644 index 00000000..051fb882 --- /dev/null +++ b/theforeman.org/pipelines/release/foreman_packaging_rpm_copr_release.groovy @@ -0,0 +1,88 @@ +def packages_to_build + +pipeline { + agent { label 'rpmbuild' } + + options { + timestamps() + timeout(time: 4, unit: 'HOURS') + disableConcurrentBuilds() + ansiColor('xterm') + } + + stages { + stage('Clone Packaging') { + steps { + script { + foreman_branch = foreman_version == 'nightly' ? "rpm/develop" : "rpm/${foreman_version}" + } + + checkout([ + $class : 'GitSCM', + branches : [[name: "*/${foreman_branch}"]], + extensions: [[$class: 'CleanCheckout']], + userRemoteConfigs: [ + [url: 'https://github.com/theforeman/foreman-packaging'] + ] + ]) + + } + } + stage('Find packages') { + steps { + copyArtifacts(projectName: env.JOB_NAME, optional: true) + + script { + + if (fileExists('commit')) { + + commit = readFile(file: 'commit').trim() + packages_to_build = find_changed_packages("${commit}..HEAD") + + } else { + + packages_to_build = [] + + } + } + } + } + stage('Release Build Packages') { + when { + expression { packages_to_build != [] } + } + steps { + + setup_obal() + + withCredentials([file(credentialsId: 'theforeman-bot-copr', variable: 'copr_config')]) { + obal( + action: "release", + extraVars: [ + 'build_package_build_system': 'copr', + 'build_package_copr_config': copr_config, + ], + packages: packages_to_build + ) + } + + } + } + } + + post { + success { + archive_git_hash() + } + failure { + notifyDiscourse( + env, + "${env.JOB_NAME} failed for ${packages_to_build.join(',')}", + "Foreman RPM packaging release job failed: ${env.BUILD_URL}" + ) + } + cleanup { + deleteDir() + } + } +} diff --git a/theforeman.org/yaml/jobs/release/foreman-packaging-rpm-release.yaml b/theforeman.org/yaml/jobs/release/foreman-packaging-rpm-release.yaml index 3d7e9323..42cc9d56 100644 --- a/theforeman.org/yaml/jobs/release/foreman-packaging-rpm-release.yaml +++ b/theforeman.org/yaml/jobs/release/foreman-packaging-rpm-release.yaml @@ -34,3 +34,31 @@ empty: '' version: - 'nightly' + +- job-template: + name: 'foreman-packaging-rpm-copr-{version}-release' + project-type: pipeline + sandbox: true + concurrent: false + properties: + - github: + url: https://github.com/theforeman/foreman-packaging + triggers: + - github + dsl: + !include-raw: + - 'pipelines/vars/foreman/{version}.groovy' + - 'pipelines/release/foreman_packaging_rpm_copr_release.groovy{empty}' + - 'pipelines/lib/git.groovy{empty}' + - 'pipelines/lib/ansible.groovy{empty}' + - 'pipelines/lib/obal.groovy{empty}' + - 'pipelines/lib/packaging.groovy{empty}' + - 'pipelines/lib/foreman_infra.groovy{empty}' + +- project: + name: foreman-packaging-rpm-copr-nightly + jobs: + - 'foreman-packaging-rpm-copr-{version}-release' + empty: '' + version: + - 'nightly'