Some checks are pending
Build Multiarch Container Image / call-reusable-workflow (push) Waiting to run
59 lines
2.5 KiB
Groovy
59 lines
2.5 KiB
Groovy
pipeline {
|
|
agent any
|
|
environment {
|
|
CONTAINER_REGISTRY = credentials("container_registry")
|
|
REGISTRY_NAMESPACE = credentials("registry_namespace")
|
|
REPO_NAME = env.GIT_URL.replaceFirst(/^.*\/([^\/]+?).git$/, '$1')
|
|
}
|
|
stages {
|
|
stage("Build") {
|
|
when { tag "*" }
|
|
steps {
|
|
script {
|
|
def architectures = ['aarch64', 'x86_64']
|
|
def parallelStages = [:]
|
|
|
|
for (arch in architectures) {
|
|
// Need to bind the label variable before the closure
|
|
def nodeLabel = arch
|
|
|
|
parallelStages[arch] = {
|
|
node(nodeLabel) {
|
|
sh "podman build -t ${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${env.BRANCH_NAME}-${nodeLabel} ."
|
|
sh "podman save -o ${nodeLabel}.tar ${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${env.BRANCH_NAME}-${nodeLabel}"
|
|
stash includes: "${nodeLabel}.tar", name: "${nodeLabel}-image"
|
|
}
|
|
}
|
|
}
|
|
|
|
parallel parallelStages
|
|
}
|
|
}
|
|
}
|
|
stage("Combine and Push") {
|
|
when { tag "*" }
|
|
agent any
|
|
steps {
|
|
unstash 'aarch64-image'
|
|
unstash 'x86_64-image'
|
|
|
|
sh "podman load -i aarch64.tar"
|
|
sh "podman load -i x86_64.tar"
|
|
|
|
sh '''
|
|
podman manifest create ${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${BRANCH_NAME} \
|
|
${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${BRANCH_NAME}-aarch64 \
|
|
${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${BRANCH_NAME}-x86_64
|
|
'''
|
|
|
|
withCredentials([usernamePassword(credentialsId: "dockerhub", usernameVariable: "REG_USERNAME", passwordVariable: "REG_PASSWORD")]) {
|
|
sh '''
|
|
podman login ${CONTAINER_REGISTRY} -u ${REG_USERNAME} -p ${REG_PASSWORD}
|
|
podman manifest push ${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${BRANCH_NAME} \
|
|
docker://${CONTAINER_REGISTRY}/${REGISTRY_NAMESPACE}/${REPO_NAME}:${BRANCH_NAME}
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|