bstinson / centos / releng

Forked from centos/releng 3 years ago
Clone
Blob Blame History Raw
arches = ['amd64', 'arm64v8', 'ppc64le'] as Set
imagepushorg = 'quay.io/centos'
manifestpushrepo = 'quay.io/centos/centos'
imagetags = ['8', '8.3.2011', 'centos8', 'latest'] as Set

node('aws'){
    for (arch in arches) {
        stage("push-$arch") {
            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 skopeo login -u=${QUAY_PUSH_USERNAME} -p ${QUAY_PUSH_PASS} quay.io'''
                        sh '''sudo skopeo copy --format v2s2 docker://docker.io/${ARCH}/centos:${TAG} docker://${IMAGEPUSHORG}/${ARCH}:${TAG}'''
                    }
                }
            }
        }
    }

    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'''
                    try{
                        sh '''sudo podman rmi ${MANIFESTPUSHREPO}:${TAG}'''
                    } catch (err) {
                    }
                    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}'''
            }
        }
    }
}