diff --git a/container-build/stream8/Jenkinsfile b/container-build/stream8/Jenkinsfile new file mode 100644 index 0000000..26d0cf4 --- /dev/null +++ b/container-build/stream8/Jenkinsfile @@ -0,0 +1,94 @@ +arches = ['amd64', 'arm64v8', 'ppc64le'] as Set +imagepushorg = 'quay.io/centos' +manifestpushrepo = 'quay.io/centos/centos' +imagetags = ['stream', 'stream8'] as Set + +for (arch in arches) { + node(arch){ + stage(arch) { + stage('Checkout') { + checkout( + scm: [ + $class: 'GitSCM', + userRemoteConfigs: [[ + url: 'https://github.com/CentOS/sig-cloud-instance-images' + ]], + branches: [[ name: '*/CentOS-8-Stream']], + ], + ) + } + + stage('Pull UBI') { + sh '''sudo podman pull registry.access.redhat.com/ubi8:latest''' + } + + stage('Build') { + sh '''sudo podman build --format docker -t localhost/centos-stream:latest docker/''' + } + + stage('Tag') { + for (tag in imagetags) { + withEnv(['TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){ + sh '''sudo podman tag localhost/centos-stream:latest ${IMAGEPUSHORG}/${ARCH}:${TAG}''' + } + } + } + + stage('Taginfo') { + for (tag in imagetags) { + withEnv(['TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){ + sh '''#!/usr/bin/env bash + set -Eeuo pipefail + mkdir -p build-info/image-ids + sudo podman inspect --format '{{ .Digest }}' ${IMAGEPUSHORG}/${ARCH}:${TAG} | tee build-info/${ARCH}-${TAG}.txt + ''' + } + } + + archiveArtifacts 'build-info/**' + } + + stage('Push') { + for (tag in imagetags) { + withEnv(['TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){ + withCredentials([usernamePassword(credentialsId: 'QUAY_PUSH', passwordVariable: 'QUAY_PUSH_PASS', usernameVariable: 'QUAY_PUSH_USERNAME')]){ + sh '''sudo podman login -u=${QUAY_PUSH_USERNAME} -p ${QUAY_PUSH_PASS} quay.io''' + sh '''sudo podman push ${IMAGEPUSHORG}/${ARCH}:${TAG}''' + } + } + } + } + } + } +} + +node('amd64'){ + stage('Create Manifests'){ + for (tag in imagetags) { + withEnv(['MANIFESTPUSHREPO='+manifestpushrepo, 'TAG='+tag, 'IMAGEPUSHORG='+imagepushorg]){ + withCredentials([usernamePassword(credentialsId: 'QUAY_PUSH', passwordVariable: 'QUAY_PUSH_PASS', usernameVariable: 'QUAY_PUSH_USERNAME')]){ + sh '''sudo podman login -u=${QUAY_PUSH_USERNAME} -p ${QUAY_PUSH_PASS} quay.io''' + sh '''sudo podman rmi ${MANIFESTPUSHREPO}:${TAG}''' + sh '''sudo podman manifest create ${MANIFESTPUSHREPO}:${TAG}''' + } + } + } + } + stage('Annotate Manifests'){ + for (tag in imagetags) { + for (arch in arches) { + withEnv(['MANIFESTPUSHREPO='+manifestpushrepo, 'TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){ + sh '''sudo podman manifest add ${MANIFESTPUSHREPO}:${TAG} docker://${IMAGEPUSHORG}/${ARCH}:${TAG}''' + } + } + } + } + stage('Push Manifests'){ + for (tag in imagetags) { + withEnv(['MANIFESTPUSHREPO='+manifestpushrepo, 'TAG='+tag]){ + sh '''sudo podman manifest push -f v2s2 --purge --all ${MANIFESTPUSHREPO}:${TAG} docker://${MANIFESTPUSHREPO}:${TAG}''' + } + } + } +} +