debian-koji-osbuild/schutzbot/Jenkinsfile
Lars Karlitski 2ac9a5b73c schutzbot: don't copy dnf repo file between stages
Repository URLs are predictable. There's no need to use Jenkins' stash
feature to pass the repo file between stages.

Instead, simply create the repo file where it is needed, in deploy.sh.
2020-11-20 19:37:45 +01:00

173 lines
5.1 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')
}
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')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
sh "schutzbot/ci_details.sh"
retry(3) {
sh "schutzbot/mockbuild.sh"
}
}
}
}
}
stage("Testing 🍌") {
parallel {
stage('F32 Integration') {
agent { label "f32cloudbase && x86_64 && aws" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
}
steps {
run_tests('integration')
}
post {
always {
preserve_logs('fedora32-integration')
}
}
}
stage('EL8 Integration') {
agent { label "rhel8cloudbase && x86_64 && psi" }
environment {
TEST_TYPE = "integration"
AWS_CREDS = credentials('aws-credentials-osbuildci')
RHN_REGISTRATION_SCRIPT = credentials('rhn-register-script-production')
}
steps {
run_tests('integration')
}
post {
always {
preserve_logs('rhel8-integration')
}
}
}
}
}
}
post {
success {
node('schutzbot') {
script {
if (env.BRANCH_NAME == 'main') {
telegramSend "💚 CI passed for koji-osbuild main branch ${env.BUILD_URL}"
}
}
}
}
unsuccessful {
node('schutzbot') {
script {
if (env.BRANCH_NAME == 'main') {
telegramSend "💣 CI failed for koji-osbuild 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"
)
if (test_type == 'integration') {
sh (
label: "Integration tests",
script: "/usr/libexec/tests/koji-osbuild/integration.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"
)
}