Skip to content

Commit

Permalink
[COST-4895] create tmp dir for build-deploy (#5028)
Browse files Browse the repository at this point in the history
  • Loading branch information
maskarb authored Apr 10, 2024
1 parent e2252b0 commit 759420c
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,18 @@ if [[ -z "$RH_REGISTRY_USER" || -z "$RH_REGISTRY_TOKEN" ]]; then
exit 1
fi

# on RHEL8 or anything else, use podman
# AUTH_CONF_DIR="$(pwd)/.podman"
# mkdir -p $AUTH_CONF_DIR
# export REGISTRY_AUTH_FILE="$AUTH_CONF_DIR/auth.json"
# podman login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io
# podman login -u="$RH_REGISTRY_USER" -p="$RH_REGISTRY_TOKEN" registry.redhat.io
# podman build -t "${IMAGE}:${IMAGE_TAG}" .
# podman push "${IMAGE}:${IMAGE_TAG}"
# # Backward compatibility with CI/QA
# podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:latest"
# podman push "${IMAGE}:latest"
# podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:qa"
# podman push "${IMAGE}:qa"
# podman tag "${IMAGE}:${IMAGE_TAG}" "${IMAGE}:clowder"
# podman push "${IMAGE}:clowder"

# on RHEL7, use docker
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 job tmp 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" build --build-arg GIT_COMMIT="$GIT_COMMIT" -t "${IMAGE}:${IMAGE_TAG}" .
Expand Down

0 comments on commit 759420c

Please sign in to comment.