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('EL8') { agent { label "rhel8cloudbase && x86_64" } environment { AWS_CREDS = credentials('aws-credentials-osbuildci') RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production') } steps { sh "schutzbot/ci_details.sh" retry(3) { sh "schutzbot/mockbuild.sh" } stash ( includes: 'osbuild-mock.repo', name: 'rhel8cdn' ) } } stage('EL8.3') { agent { label "rhel83cloudbase && x86_64" } environment { AWS_CREDS = credentials('aws-credentials-osbuildci') RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta') } steps { sh "schutzbot/ci_details.sh" retry(3) { sh "schutzbot/mockbuild.sh" } stash ( includes: 'osbuild-mock.repo', name: 'rhel83' ) } } } } stage("Testing 🍌") { parallel { stage('EL8 Integration') { agent { label "rhel8cloudbase && x86_64" } environment { TEST_TYPE = "integration" AWS_CREDS = credentials('aws-credentials-osbuildci') RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production') } steps { unstash 'rhel8cdn' run_tests('integration') } post { always { preserve_logs('rhel8-integration') } } } stage('EL8.3 Base') { agent { label "rhel83cloudbase && x86_64" } environment { TEST_TYPE = "base" RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta') } steps { unstash 'rhel83' run_tests('base') } post { always { preserve_logs('rhel83-base') } } } stage('EL8.3 Image') { agent { label "rhel83cloudbase && psi && x86_64" } environment { TEST_TYPE = "image" AWS_CREDS = credentials('aws-credentials-osbuildci') AZURE_CREDS = credentials('azure') OPENSTACK_CREDS = credentials("psi-openstack-creds") RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta') VCENTER_CREDS = credentials('vmware-vcenter-credentials') } steps { unstash 'rhel83' run_tests('image') } post { always { preserve_logs('rhel83-image') } } } stage('EL8.3 Integration') { agent { label "rhel83cloudbase && x86_64" } environment { TEST_TYPE = "integration" AWS_CREDS = credentials('aws-credentials-osbuildci') RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-beta') } steps { unstash 'rhel83' run_tests('integration') } post { always { preserve_logs('rhel83-integration') } } } } } } post { success { node('schutzbot') { script { if (env.BRANCH_NAME == 'rhel-8.3.0') { telegramSend "💚 CI passed for osbuild-composer ${env.BRANCH_NAME} branch ${env.BUILD_URL}" } } } } unsuccessful { node('schutzbot') { script { if (env.BRANCH_NAME == 'rhel-8.3.0') { telegramSend "💣 CI failed for osbuild-composer ${env.BRANCH_NAME} 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: "schutzbot/run_base_tests.sh" ) } if (test_type == 'image') { sh ( label: "Image tests", script: "schutzbot/run_image_tests.sh" ) } if (test_type == 'integration') { // Run the qcow2 test. sh ( label: "Integration test: QCOW2", script: "test/image-tests/qemu.sh qcow2" ) // Run the openstack test. sh ( label: "Integration test: OpenStack", script: "test/image-tests/qemu.sh openstack" ) // Run the VHD/Azure test. sh ( label: "Integration test: VHD", script: "test/image-tests/qemu.sh vhd" ) // Run the AWS test. sh ( label: "Integration test: AWS", script: "test/image-tests/aws.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" // Artifact the logs. archiveArtifacts ( allowEmptyArchive: true, artifacts: "${test_slug}/*.log,${test_slug}/*.jpg" ) }