From 12e76139285c69ae4ea104a9ea16f6371838890c Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sun, 17 Nov 2024 20:04:12 +0100 Subject: [PATCH] dded registrymirror --- vars/buildcontainer.groovy | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vars/buildcontainer.groovy b/vars/buildcontainer.groovy index f7d6d94..a77493f 100644 --- a/vars/buildcontainer.groovy +++ b/vars/buildcontainer.groovy @@ -1,3 +1,5 @@ +import java.rmi.dgc.VMID + // Builds a docker container. This requires the kaniko container to be included using agentsetup // // Mandatory arguments: @@ -14,15 +16,21 @@ def call(Map args) { def defaults = [ cache: true, cachettl: "14d", - dockerfile: 'Dockerfile', + dockerfile: 'Dockerfile', + mirror: env.REGISTRY_MIRROR, repo: env.CONTAINER_REGISTRY, version: env.BRANCH_NAME + "-latest" ] args = defaults << args + + mirrorArg = "" + if (args.mirror) { + mirrorArg = "--registry-mirror ${mirrorArg}" + } container('kaniko') { sh """ echo "Building container with settings: ${args}" - /kaniko/executor --dockerfile ${args.dockerfile} --cache=${args.cache} --cache-ttl=${args.cachettl} --context \$( pwd )/${args.context} --destination ${args.repo}/${args.container}:${args.version} + /kaniko/executor $mirrorArg --dockerfile ${args.dockerfile} --cache=${args.cache} --cache-ttl=${args.cachettl} --context \$( pwd )/${args.context} --destination ${args.repo}/${args.container}:${args.version} rm -rf /kaniko/*[0-9]* && rm -rf /kaniko/Dockerfile && mkdir -p /workspace """ } -- 2.31.1