From 13e44fa5203fb05bbc62e373b34cc2b6bd713aa3 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 22 Mar 2023 10:36:18 -0700 Subject: [PATCH] Add support for passing env vars to the container build env This is useful if you are using docker and wish to enable buildkit for example. Change-Id: I69ae90d945fa3f4eabc10460da936b23c8212858 --- roles/build-container-image/common.rst | 6 ++++++ roles/build-container-image/defaults/main.yaml | 1 + roles/build-container-image/tasks/build.yaml | 1 + 3 files changed, 8 insertions(+) diff --git a/roles/build-container-image/common.rst b/roles/build-container-image/common.rst index 6e304a553..cbcfbdd9a 100644 --- a/roles/build-container-image/common.rst +++ b/roles/build-container-image/common.rst @@ -165,4 +165,10 @@ using the roles described here. added with each sibling project. Note that projects here must be listed in ``required-projects``. +.. zuul:rolevar:: container_build_extra_env + :type: dict + + A dictionary of key value pairs to add to the container build environment. + This may be useful to enable buildkit with docker builds for example. + .. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor// diff --git a/roles/build-container-image/defaults/main.yaml b/roles/build-container-image/defaults/main.yaml index 916550c08..751860598 100644 --- a/roles/build-container-image/defaults/main.yaml +++ b/roles/build-container-image/defaults/main.yaml @@ -1,2 +1,3 @@ zuul_work_dir: "{{ zuul.project.src_dir }}" container_command: podman +container_build_extra_env: {} diff --git a/roles/build-container-image/tasks/build.yaml b/roles/build-container-image/tasks/build.yaml index e1bcd21ee..098d484a6 100644 --- a/roles/build-container-image/tasks/build.yaml +++ b/roles/build-container-image/tasks/build.yaml @@ -52,6 +52,7 @@ {% endfor -%} args: chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}" + environment: "{{ container_build_extra_env }}" - name: Cleanup sibling source directory file: