+import java.rmi.dgc.VMID
+
// Builds a docker container. This requires the kaniko container to be included using agentsetup
//
// Mandatory arguments:
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
"""
}