From 8ed694c44ad8352a825d9c2dd90c31d730c70cc1 Mon Sep 17 00:00:00 2001 From: Petra Cihalova <89980168+petracihalova@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:08:58 +0100 Subject: [PATCH] use temp directory for docker config (#251) --- build_deploy.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build_deploy.sh b/build_deploy.sh index 5ff2679..b6f7a81 100755 --- a/build_deploy.sh +++ b/build_deploy.sh @@ -18,7 +18,19 @@ if [[ -z "$RH_REGISTRY_USER" || -z "$RH_REGISTRY_TOKEN" ]]; then exit 1 fi -DOCKER_CONF="$PWD/.docker" +# Create tmp dir to store data in during job run (do NOT store in $WORKSPACE) +export TMP_JOB_DIR=$(mktemp -d -p "$HOME" -t "jenkins-${JOB_NAME}-${BUILD_NUMBER}-XXXXXX") +echo "job tmp dir location: $TMP_JOB_DIR" + +function job_cleanup() { + echo "cleaning up tmp job dir: $TMP_JOB_DIR" + rm -fr $TMP_JOB_DIR +} + +trap job_cleanup EXIT ERR SIGINT SIGTERM + +DOCKER_CONF="$TMP_JOB_DIR/.docker" + mkdir -p "$DOCKER_CONF" docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io docker --config="$DOCKER_CONF" login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io