debian-forge-composer/schutzbot/Jenkinsfile
Jacob Kozol 7b40a3b38e schutzbot: add rhel 8.4 tests to jenkins pipeline
rhel 8.4 tests are added. The configs are based off of those used for
rhel 8.3. The Schutzbot Mockbuild, Base, Image, Integration, and OSTree
tests are added for 8.4. Repo overrides are added for the rhel 8.4 tests
so that the tests use rpmrepo snapshots.

The mockbuild uses the jenkins rhel84-nightly-repo credential to
override the rhel mock template's repos with rhel 8.4 nightly repos.
These repos are stored in a credential because they are internal links.

The image tests and koji tests need a special distro selector since the
rhel-8 test cases are only for rhel 8 versions less than 8.4. The rhel
8.4 tests are named with the rhel-84 pattern whereas the other rhel 8
versions have the rhel-8 pattern.

Also, instead of having only rhel-8 and rhel-8-beta repo configs for the
tests, we now have a specific repo config for each rhel release we test.
The repo is also now pulled from an rpmrepo snapshot. For whichever
distro is being tested, the approriate repo config will be copied to
/etc/osbuild-composer/repositories as rhel-8 and rhel-8-beta since this
is the naming osbuild-composer looks for. For testing purposes, the
rhel-8 and rhel-8-beta repo should be the same since eventually all rhel
releases will go from beta to not beta. The fedora repo overrides are
already done in tools/provision.sh so the rhel override is set there as
well. Currently, only rhel 8.4 requires an override.
2020-11-19 10:36:49 +01:00

482 lines
17 KiB
Groovy

pipeline {
agent none
environment {
AWS_REGION = "us-east-2"
AWS_BUCKET = "imagebuilder-jenkins-testing-use2"
}
options {
timestamps()
ansiColor('xterm')
// Cancel the pipeline if it runs for more than three hours.
timeout(
time: 3,
unit: "HOURS"
)
}
stages {
stage("Prepare 🤔") {
agent { label "schutzbot" }
options {
// Don't checkout the git repository here. It just clogs
// up the Jenkins disk space and does nothing for us.
skipDefaultCheckout()
}
steps {
sh (
label: "Get environment variables",
script: "env | sort"
)
}
}
stage("Mock build 👷🏻") {
// Halt the pipeline immediately if a single mock build fails.
// A failure to build an RPM is serious and must be
// investigated.
failFast true
parallel {
stage('F32') {
agent { label "f32cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
}
}
stage('F33') {
agent { label "f33cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
}
}
stage('EL8') {
agent { label "rhel8cloudbase && x86_64 && aws" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
}
}
stage('EL8.4') {
agent { label "rhel84cloudbase && x86_64 && psi" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHEL84_NIGHTLY_REPO = credentials('rhel84-nightly-repo')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
}
}
}
}
stage("Testing 🍌") {
parallel {
stage('F32 Base') {
agent { label "f32cloudbase && x86_64 && aws" }
environment { TEST_TYPE = "base" }
steps {
run_tests('base')
}
post {
always {
preserve_logs('fedora32-base')
}
}
}
stage('F32 Image') {
agent { label "f32cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure')
OPENSTACK_CREDS = credentials("psi-openstack-creds")
VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "fedora32"
}
steps {
run_tests('image')
}
post {
always {
preserve_logs('fedora32-image')
sh (
label: "Run cloud cleaner just in case something failed",
script: "schutzbot/run_cloud_cleaner.sh"
)
}
}
}
stage('F32 Integration') {
agent { label "f32cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
run_tests('integration')
}
post {
always {
preserve_logs('fedora32-integration')
}
}
}
stage('F32 OSTree') {
agent { label "f32cloudbase && psi && x86_64" }
steps {
run_tests('ostree')
}
post {
always {
preserve_logs('fedora32-ostree')
}
}
}
stage('F33 Base') {
agent { label "f33cloudbase && x86_64 && aws" }
environment { TEST_TYPE = "base" }
steps {
run_tests('base')
}
post {
always {
preserve_logs('fedora33-base')
}
}
}
stage('F33 Image') {
agent { label "f33cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure')
OPENSTACK_CREDS = credentials("psi-openstack-creds")
VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "fedora33"
}
steps {
run_tests('image')
}
post {
always {
preserve_logs('fedora33-image')
}
}
}
stage('F33 Integration') {
agent { label "f33cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
run_tests('integration')
}
post {
always {
preserve_logs('fedora33-integration')
}
}
}
stage('F33 OSTree') {
agent { label "f33cloudbase && psi && x86_64" }
steps {
run_tests('ostree')
}
post {
always {
preserve_logs('fedora33-ostree')
}
}
}
stage('EL8 Base') {
agent { label "rhel8cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "base"
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
run_tests('base')
}
post {
always {
preserve_logs('rhel8-base')
}
}
}
stage('EL8 Image') {
agent { label "rhel8cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure')
OPENSTACK_CREDS = credentials("psi-openstack-creds")
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "rhel8"
}
steps {
run_tests('image')
}
post {
always {
preserve_logs('rhel8-image')
sh (
label: "Run cloud cleaner just in case something failed",
script: "schutzbot/run_cloud_cleaner.sh"
)
}
}
}
stage('EL8 Integration') {
agent { label "rhel8cloudbase && x86_64 && psi" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
run_tests('integration')
}
post {
always {
preserve_logs('rhel8-integration')
}
}
}
stage('EL8 OSTree') {
agent { label "rhel8cloudbase && psi && x86_64" }
steps {
run_tests('ostree')
}
post {
always {
preserve_logs('rhel8-ostree')
}
}
}
stage('EL8.4 Base') {
agent { label "rhel84cloudbase && x86_64 && psi" }
environment {
TEST_TYPE = "base"
}
steps {
run_tests('base')
}
post {
always {
preserve_logs('rhel84-base')
}
}
}
stage('EL8.4 Image') {
agent { label "rhel84cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
AZURE_CREDS = credentials('azure')
OPENSTACK_CREDS = credentials("psi-openstack-creds")
VCENTER_CREDS = credentials('vmware-vcenter-credentials')
DISTRO_CODE = "rhel84"
}
steps {
run_tests('image')
}
post {
always {
preserve_logs('rhel84-image')
sh (
label: "Run cloud cleaner just in case something failed",
script: "schutzbot/run_cloud_cleaner.sh"
)
}
}
}
stage('EL8.4 Integration') {
agent { label "rhel84cloudbase && x86_64 && psi" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
AWS_IMAGE_TEST_CREDS = credentials('aws-credentials-osbuild-image-test')
}
steps {
run_tests('integration')
}
post {
always {
preserve_logs('rhel84-integration')
}
}
}
stage('EL8.4 OSTree') {
agent { label "rhel84cloudbase && psi && x86_64" }
steps {
run_tests('ostree')
}
post {
always {
preserve_logs('rhel84-ostree')
}
}
}
}
}
}
post {
success {
node('schutzbot') {
script {
if (env.BRANCH_NAME == 'main') {
telegramSend "💚 CI passed for osbuild-composer main branch ${env.BUILD_URL}"
}
}
}
}
unsuccessful {
node('schutzbot') {
script {
if (env.BRANCH_NAME == 'main') {
telegramSend "💣 CI failed for osbuild-composer main branch ${env.BUILD_URL}"
}
}
}
}
}
}
// Set up a function to hold the steps needed to run the tests so we don't
// need to copy/paste the same lines over and over above.
void run_tests(test_type) {
// Get CI machine details.
sh (
label: "Get CI machine details",
script: "schutzbot/ci_details.sh"
)
// Deploy the Image Builder packages and services.
sh (
label: "Deploy",
script: "schutzbot/deploy.sh"
)
// Run the base tests.
if (test_type == 'base') {
sh (
label: "Base tests",
script: "/usr/libexec/tests/osbuild-composer/base_tests.sh"
)
}
if (test_type == 'image') {
sh (
label: "Image tests",
script: "/usr/libexec/tests/osbuild-composer/image_tests.sh"
)
}
if (test_type == 'ostree') {
sh (
label: "OSTree tests",
script: "/usr/libexec/tests/osbuild-composer/ostree.sh"
)
}
if (test_type == 'integration') {
// Run Koji tests.
sh (
label: "Koji tests",
script: "/usr/libexec/tests/osbuild-composer/koji.sh"
)
// Run the qcow2 test.
sh (
label: "Integration test: QCOW2",
script: "/usr/libexec/tests/osbuild-composer/qemu.sh qcow2"
)
// Run the openstack test.
sh (
label: "Integration test: OpenStack",
script: "/usr/libexec/tests/osbuild-composer/qemu.sh openstack"
)
// Run the VHD/Azure test.
sh (
label: "Integration test: VHD",
script: "/usr/libexec/tests/osbuild-composer/qemu.sh vhd"
)
// Run the AWS test.
sh (
label: "Integration test: AWS",
script: "/usr/libexec/tests/osbuild-composer/aws.sh"
)
// Run the API test.
sh (
label: "Integration test: API",
script: "/usr/libexec/tests/osbuild-composer/api.sh"
)
}
}
// Move logs to a unique location and tell Jenkins to capture them on success
// or failure.
void preserve_logs(test_slug) {
// Save the systemd journal.
sh "journalctl --boot > systemd-journald.log"
// Make a directory for the log files and move the logs there.
sh "mkdir ${test_slug} && mv *.log *.jpg ${test_slug}/ || true"
// The workspace directory is not used everywhere, tests use temporary directory under /tmp/logs.
sh "mkdir -p ${test_slug} && find /tmp/logs/ -name '*.log' -exec mv {} ${test_slug}/ \\; || true"
// Artifact the logs.
archiveArtifacts (
allowEmptyArchive: true,
artifacts: "${test_slug}/*.log,${test_slug}/*.jpg"
)
}