debian-forge-composer/schutzbot/Jenkinsfile
Major Hayden 45c159e7f8 🦾 Add aarch64 base tests; restructure stages
Add base aarch64 tests for Fedora 31/32 and RHEL 8 CDN.

Also restructure the pipeline so that a slow distro or slow architecture
won't hold up the faster-moving tests.

This helps a bit more with #834.

Signed-off-by: Major Hayden <major@redhat.com>
2020-07-14 14:25:40 +01:00

481 lines
19 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" }
steps {
sh (
label: "Get environment variables",
script: "env | sort"
)
}
}
// The outermost testing stage consists of multiple parallel lanes
// that allow tests to keep going with a single OS/arch combination
// without waiting on others. This is handy if one OS has slow mirrors
// or the arch is generally slower, like aarch64.
stage("Test 🤔") {
parallel {
// Fedora 31 on x86 has a full suite of tests and can run in
// AWS or PSI.
stage("F31 x86") {
stages {
stage('Mock build') {
agent { label "f31cloudbase && x86_64" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'fedora31'
)
}
}
stage('Base') {
agent { label "f31cloudbase && x86_64" }
environment { TEST_TYPE = "base" }
steps {
unstash 'fedora31'
run_tests('base')
}
post {
always {
preserve_logs('fedora31-base')
}
}
}
stage('Image') {
agent { label "f31cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
unstash 'fedora31'
run_tests('image')
}
post {
always {
preserve_logs('fedora31-image')
}
}
}
stage('Integration') {
agent { label "f31cloudbase && x86_64" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
unstash 'fedora31'
run_tests('integration')
}
post {
always {
preserve_logs('fedora31-integration')
}
}
}
}
}
// Fedora 31 on aarch64 has base tests enabled and can only
// run at AWS.
stage("F31 aarch64") {
stages {
stage('Mock build') {
agent { label "f31cloudbase_aarch64_temporary" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'fedora31_aarch64'
)
}
}
stage('Base') {
agent { label "f31cloudbase_aarch64_temporary" }
environment { TEST_TYPE = "base" }
steps {
unstash 'fedora31_aarch64'
run_tests('base')
}
post {
always {
preserve_logs('fedora31-base')
}
}
}
}
}
// Fedora 32 on x86 has a full suite of tests and can run in
// AWS or PSI.
stage("F32 x86") {
stages {
stage('Mock build') {
agent { label "f32cloudbase && x86_64" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'fedora32'
)
}
}
stage('Base') {
agent { label "f32cloudbase && x86_64" }
environment { TEST_TYPE = "base" }
steps {
unstash 'fedora32'
run_tests('base')
}
post {
always {
preserve_logs('fedora32-base')
}
}
}
stage('Image') {
agent { label "f32cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
unstash 'fedora32'
run_tests('image')
}
post {
always {
preserve_logs('fedora32-image')
}
}
}
stage('Integration') {
agent { label "f32cloudbase && x86_64" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
unstash 'fedora32'
run_tests('integration')
}
post {
always {
preserve_logs('fedora32-integration')
}
}
}
}
}
// Fedora 32 on aarch64 has base tests enabled and can only
// run at AWS.
stage("F32 aarch64") {
stages {
stage('Mock build') {
agent { label "f32cloudbase_aarch64_temporary" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'fedora32_aarch64'
)
}
}
stage('Base') {
agent { label "f32cloudbase_aarch64_temporary" }
environment { TEST_TYPE = "base" }
steps {
unstash 'fedora32_aarch64'
run_tests('base')
}
post {
always {
preserve_logs('fedora32-base')
}
}
}
}
}
// RHEL 8 on x86 has a full suite of tests and can run in
// AWS or PSI.
stage("RHEL8 x86") {
stages {
stage('Mock build') {
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('Base') {
agent { label "rhel8cloudbase && x86_64" }
environment {
TEST_TYPE = "base"
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
unstash 'rhel8cdn'
run_tests('base')
}
post {
always {
preserve_logs('rhel8-base')
}
}
}
stage('Image') {
agent { label "rhel8cloudbase && psi && x86_64" }
environment {
TEST_TYPE = "image"
AWS_CREDS = credentials('aws-credentials-osbuildci')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
unstash 'rhel8cdn'
run_tests('image')
}
post {
always {
preserve_logs('rhel8-image')
}
}
}
stage('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')
}
}
}
}
}
// RHEL 8 on aarch64 has base tests enabled and can only
// run at AWS.
stage("RHEL8 aarch64") {
stages {
stage('Mock build') {
agent { label "rhel8cloudbase_aarch64_temporary" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-aarch64')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'rhel8cdn_aarch64'
)
}
}
stage('Base') {
agent { label "rhel8cloudbase_aarch64_temporary" }
environment {
TEST_TYPE = "base"
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production-aarch64')
}
steps {
unstash 'rhel8cdn_aarch64'
run_tests('base')
}
post {
always {
preserve_logs('fedora32-base')
}
}
}
}
}
// RHEL 8.3 on x86 has a full suite of tests and can only run
// in PSI until 8.3 beta content appears on the public CDN.
stage("RHEL8.3 x86") {
stages {
stage('RHEL 8.3 Nightly') {
agent { label "rhel83cloudbase && x86_64" }
environment {
AWS_CREDS = credentials('aws-credentials-osbuildci')
NIGHTLY_REPO = credentials('rhel8-nightly-repo')
NIGHTLY_MOCK_TEMPLATE = credentials('rhel8-nightly-mock-template')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
stash (
includes: 'osbuild-mock.repo',
name: 'rhel83'
)
}
}
stage('RHEL 8.3 Base') {
agent { label "rhel83cloudbase && x86_64" }
environment { TEST_TYPE = "base" }
steps {
unstash 'rhel83'
run_tests('base')
}
post {
always {
preserve_logs('rhel83-base')
}
}
}
}
}
}
}
}
}
// 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 VMDK/VMware test.
sh (
label: "Integration test: VMDK",
script: "test/image-tests/qemu.sh vmdk"
)
// 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"
)
}