Blame container-build/stream8/Jenkinsfile

Brian Stinson 57723a
arches = ['amd64', 'arm64v8', 'ppc64le'] as Set
Brian Stinson 57723a
imagepushorg = 'quay.io/centos'
Brian Stinson 57723a
manifestpushrepo = 'quay.io/centos/centos'
Brian Stinson 57723a
imagetags = ['stream', 'stream8'] as Set
Brian Stinson 57723a
Brian Stinson 57723a
for (arch in arches) {
Brian Stinson 57723a
    node(arch){
Brian Stinson 57723a
        stage(arch) {
Brian Stinson 57723a
            stage('Checkout') {
Brian Stinson 57723a
                checkout(
Brian Stinson 57723a
                        scm: [
Brian Stinson 57723a
                        $class: 'GitSCM',
Brian Stinson 57723a
                        userRemoteConfigs: [[
Brian Stinson 57723a
                        url: 'https://github.com/CentOS/sig-cloud-instance-images'
Brian Stinson 57723a
                        ]],
Brian Stinson 6e91dd
                        extensions: [
Brian Stinson 6e91dd
                            [$class: 'SparseCheckoutPaths',  sparseCheckoutPaths:[[$class:'SparseCheckoutPath', path:'docker/']]],
Brian Stinson 6e91dd
                            [$class: 'CleanBeforeCheckout'], 
Brian Stinson 6e91dd
                            [$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true, timeout: 10]
Brian Stinson 6e91dd
                        ],
Brian Stinson 57723a
                        branches: [[ name: '*/CentOS-8-Stream']],
Brian Stinson 57723a
                        ],
Brian Stinson 57723a
                        )
Brian Stinson 57723a
            }
Brian Stinson 57723a
Brian Stinson 57723a
            stage('Pull UBI') {
Brian Stinson 57723a
                sh '''sudo podman pull registry.access.redhat.com/ubi8:latest'''
Brian Stinson 57723a
            }
Brian Stinson 57723a
Brian Stinson 57723a
            stage('Build') {
Brian Stinson 57723a
                sh '''sudo podman build --format docker -t localhost/centos-stream:latest docker/'''
Brian Stinson 57723a
            }
Brian Stinson 57723a
Brian Stinson 57723a
            stage('Tag') {
Brian Stinson 57723a
                for (tag in imagetags) {
Brian Stinson 57723a
                    withEnv(['TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){
Brian Stinson 57723a
                        sh '''sudo podman tag localhost/centos-stream:latest ${IMAGEPUSHORG}/${ARCH}:${TAG}'''
Brian Stinson 57723a
                    }
Brian Stinson 57723a
                }
Brian Stinson 57723a
            }
Brian Stinson 57723a
Brian Stinson 57723a
            stage('Taginfo') {
Brian Stinson 57723a
                for (tag in imagetags) {
Brian Stinson 57723a
                    withEnv(['TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){
Brian Stinson 57723a
                        sh '''#!/usr/bin/env bash
Brian Stinson 57723a
                            set -Eeuo pipefail
Brian Stinson 57723a
                            mkdir -p build-info/image-ids
Brian Stinson 57723a
                            sudo podman inspect --format '{{ .Digest }}' ${IMAGEPUSHORG}/${ARCH}:${TAG} | tee build-info/${ARCH}-${TAG}.txt
Brian Stinson 57723a
                            '''
Brian Stinson 57723a
                    }
Brian Stinson 57723a
                }
Brian Stinson 57723a
Brian Stinson 57723a
                archiveArtifacts 'build-info/**'
Brian Stinson 57723a
            }
Brian Stinson 57723a
Brian Stinson 57723a
            stage('Push') {
Brian Stinson 57723a
                for (tag in imagetags) {
Brian Stinson 57723a
                    withEnv(['TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){
Brian Stinson 57723a
                        withCredentials([usernamePassword(credentialsId: 'QUAY_PUSH', passwordVariable: 'QUAY_PUSH_PASS', usernameVariable: 'QUAY_PUSH_USERNAME')]){
Brian Stinson 57723a
                            sh '''sudo podman login -u=${QUAY_PUSH_USERNAME} -p ${QUAY_PUSH_PASS} quay.io'''
Brian Stinson 57723a
                            sh '''sudo podman push ${IMAGEPUSHORG}/${ARCH}:${TAG}'''
Brian Stinson 57723a
                        }
Brian Stinson 57723a
                   }
Brian Stinson 57723a
                }
Brian Stinson 57723a
            }
Brian Stinson 57723a
        }
Brian Stinson 57723a
    }
Brian Stinson 57723a
}
Brian Stinson 57723a
Brian Stinson 57723a
node('amd64'){
Brian Stinson 57723a
    stage('Create Manifests'){
Brian Stinson 57723a
        for (tag in imagetags) {
Brian Stinson 57723a
            withEnv(['MANIFESTPUSHREPO='+manifestpushrepo, 'TAG='+tag, 'IMAGEPUSHORG='+imagepushorg]){
Brian Stinson 57723a
                withCredentials([usernamePassword(credentialsId: 'QUAY_PUSH', passwordVariable: 'QUAY_PUSH_PASS', usernameVariable: 'QUAY_PUSH_USERNAME')]){
Brian Stinson 57723a
                    sh '''sudo podman login -u=${QUAY_PUSH_USERNAME} -p ${QUAY_PUSH_PASS} quay.io'''
Brian Stinson 84df9b
                    try{
Brian Stinson 84df9b
                        sh '''sudo podman rmi ${MANIFESTPUSHREPO}:${TAG}'''
Brian Stinson 84df9b
                    } catch (err) {
Brian Stinson 84df9b
                    }
Brian Stinson 57723a
                    sh '''sudo podman manifest create ${MANIFESTPUSHREPO}:${TAG}'''
Brian Stinson 57723a
                }
Brian Stinson 57723a
            }
Brian Stinson 57723a
        }
Brian Stinson 57723a
    }
Brian Stinson 57723a
    stage('Annotate Manifests'){
Brian Stinson 57723a
        for (tag in imagetags) {
Brian Stinson 57723a
            for (arch in arches) {
Brian Stinson 57723a
                withEnv(['MANIFESTPUSHREPO='+manifestpushrepo, 'TAG='+tag, 'ARCH='+arch, 'IMAGEPUSHORG='+imagepushorg]){
Brian Stinson 57723a
                    sh '''sudo podman manifest add ${MANIFESTPUSHREPO}:${TAG} docker://${IMAGEPUSHORG}/${ARCH}:${TAG}'''
Brian Stinson 57723a
                }
Brian Stinson 57723a
            }
Brian Stinson 57723a
        }
Brian Stinson 57723a
    }
Brian Stinson 57723a
    stage('Push Manifests'){
Brian Stinson 57723a
        for (tag in imagetags) {
Brian Stinson 57723a
            withEnv(['MANIFESTPUSHREPO='+manifestpushrepo, 'TAG='+tag]){
Brian Stinson 57723a
                sh '''sudo podman manifest push -f v2s2 --purge --all ${MANIFESTPUSHREPO}:${TAG} docker://${MANIFESTPUSHREPO}:${TAG}'''
Brian Stinson 57723a
            }
Brian Stinson 57723a
        }
Brian Stinson 57723a
    }
Brian Stinson 57723a
}
Brian Stinson 57723a