Commit 56934984 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Redesign BUILD_ARGS in build-image.yml template

As dollar symbols ($) are apparently a big problem in the values of CI
pipeline variables passed through triggers, BUILD_ARGS has a new syntax
that avoids them.

This should not impact any pipelines except one, which is being changed
in parallel with this change.
parent ff568a43
Loading
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -45,6 +45,16 @@
# PLATFORMS:
#   A comma separated list of Docker/OCI platforms to build images for
#   (default: linux/amd64, linux/arm64)
#
# BUILD_ARGS:
#   ENVVAR[:BUILD-ARG] [ENVVAR[:BUILD-ARG] ...]
#   A space separated list of environment variables to pass as build arguments.
#   If only an environment variable name is given, it will be passed as
#   a build argument of the same name. If a pair of names separated by a colon
#   is given then the first is the environment variable and the second is the
#   build argument name.  The values are parsed as shell arguments so use quotes
#   or escapes for whitespace.  Be aware that all embedded variables will be
#   expanded before child pipelines are triggered.


variables:
@@ -72,10 +82,14 @@ Build:
    . build.env
  - |
    : buildctl build ...
    opts() { test $# -eq 0 || printf "--opt\0build-arg:%s\0" "$@"; }
    build()
    {
      opts "$@" | xargs -0 buildctl build \
      local arg val
      for arg in "$@"; do
        eval "val=\$${arg%:*}"
        printf "--opt\0build-arg:%s=%s\0" "${arg#*:}" "${val}"
      done |
      xargs -0 buildctl build \
      --frontend dockerfile.v0 \
      --local context=. \
      --local dockerfile=. \
@@ -85,7 +99,7 @@ Build:
      ${PLATFORMS:+--opt platform=${PLATFORMS// }} \
      ${TARGET+--opt target=$TARGET}
    }
    eval "build ${BUILD_ARGS}"
    eval "build ${BUILD_ARGS-}"
  artifacts:
    reports:
      dotenv: build.env