From: Erik Brakkee Date: Sun, 17 Nov 2024 19:30:59 +0000 (+0100) Subject: now checking for mandatory image argument X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=00cca7fdc19b00a337f62a09239c407bb5cd4da7;p=pipelinelib now checking for mandatory image argument --- diff --git a/vars/buildcontainer.groovy b/vars/buildcontainer.groovy index 3bd6ae2..b1a01ca 100644 --- a/vars/buildcontainer.groovy +++ b/vars/buildcontainer.groovy @@ -3,10 +3,10 @@ import java.rmi.dgc.VMID // Builds a docker container. This requires the kaniko container to be included using agentsetup // // Mandatory arguments: -// - context: the relative path in the source repository to the directory where the docker file is located -// - container: the name of the container to build +// - image: the name of the container to build // // Optional arguments: +// - context: the relative path in the source repository to the directory where the docker file is located // - cache: Whether to use the cache for building containers. Defaults to true // - dockerfile: Name of the docker file in the context directory. Defaults to Dockerfile // - repo: Repository to publish container to. Defaults to the CONTAINER_REGISTRY environment variable @@ -23,7 +23,9 @@ def call(Map args) { version: env.BRANCH_NAME + "-latest" ] args = defaults << args - + if (!args.image) { + error("'image' must be specified") + } mirrorArg = "" if (args.mirror) { mirrorArg = "--registry-mirror '${args.mirror}'" @@ -37,7 +39,7 @@ def call(Map args) { --dockerfile ${args.dockerfile} \\ --cache=${args.cache} --cache-ttl=${args.cachettl} \\ --context \$( pwd )/${args.context} \\ - --destination ${args.repo}/${args.container}:${args.version} + --destination ${args.repo}/${args.image}:${args.version} rm -rf /kaniko/*[0-9]* && rm -rf /kaniko/Dockerfile && mkdir -p /workspace """ }