From 2fd4982e05fb42c3f7684839591e3c80d930f098 Mon Sep 17 00:00:00 2001 From: Luke Kingland Date: Tue, 19 Nov 2024 11:59:01 +0000 Subject: [PATCH] fix: set DOCKER_CONFIG prior to build (#2580) --- pkg/pipelines/tekton/tasks.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/pipelines/tekton/tasks.go b/pkg/pipelines/tekton/tasks.go index c1773251c..d311d1a94 100644 --- a/pkg/pipelines/tekton/tasks.go +++ b/pkg/pipelines/tekton/tasks.go @@ -351,17 +351,26 @@ spec: TLS_VERIFY_FLAG="--tls-verify=false" fi + # Set certificate directory flag if workspace is bound [[ "$(workspaces.sslcertdir.bound)" == "true" ]] && CERT_DIR_FLAG="--cert-dir $(workspaces.sslcertdir.path)" + + # Set docker config before any buildah commands + [[ "$(workspaces.dockerconfig.bound)" == "true" ]] && export DOCKER_CONFIG="$(workspaces.dockerconfig.path)" + + # Setup artifacts cache path ARTIFACTS_CACHE_PATH="$(workspaces.cache.path)/mvn-artifacts" [ -d "${ARTIFACTS_CACHE_PATH}" ] || mkdir "${ARTIFACTS_CACHE_PATH}" + + # Build the image buildah ${CERT_DIR_FLAG} bud --storage-driver=vfs ${TLS_VERIFY_FLAG} --layers \ -v "${ARTIFACTS_CACHE_PATH}:/tmp/artifacts/:rw,z,U" \ -f /gen-source/Dockerfile.gen -t $(params.IMAGE) . - [[ "$(workspaces.dockerconfig.bound)" == "true" ]] && export DOCKER_CONFIG="$(workspaces.dockerconfig.path)" + # Push the image buildah ${CERT_DIR_FLAG} push --storage-driver=vfs ${TLS_VERIFY_FLAG} --digestfile $(workspaces.source.path)/image-digest \ $(params.IMAGE) docker://$(params.IMAGE) + # Output the image digest cat $(workspaces.source.path)/image-digest | tee /tekton/results/IMAGE_DIGEST volumeMounts: - name: varlibcontainers