From: Erik Brakkee Date: Sun, 17 Nov 2024 19:04:12 +0000 (+0100) Subject: dded registrymirror X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=12e76139285c69ae4ea104a9ea16f6371838890c;p=pipelinelib dded registrymirror --- 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 """ }