// 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
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}'"
--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
"""
}