Skip to content

Commit

Permalink
fix date and buildname
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed May 21, 2024
1 parent 61674c4 commit e6f9c95
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# check if all required variables are set
if [ -z "$APP" ] || [ -z "$PHASE" ] || [ -z "$PIPELINE" ] || [ -z "$REPOSITORY" ] || [ -z "$TAG" ] || [ -z "$SERVICE_ACCOUNT" ] || [ -z "$BUILDER" ] || [ -z "$URL" ] || [ -z "$REVISION" ]; then
echo "$(date -u) One or more required variables are not set"
echo "$(date) One or more required variables are not set"
exit 1
fi

Expand All @@ -25,24 +25,24 @@ EOF

# check if kubectl command failed
if [ $? -ne 0 ]; then
echo "$(date -u) Failed to create build pod"
echo "$(date) Failed to create build pod"
exit 1
fi

sleep 2

## check with kubectl if the pod is completed
while true; do
PHASE=$(kubectl get pod ${NAME}-build-pod -o jsonpath='{.status.phase}')
PHASE=$(kubectl get pod ${APP}-${TAG}-build-pod -o jsonpath='{.status.phase}')
if [ "$PHASE" == "Succeeded" ]; then
echo "$(date -u) Build completed successfully"
echo "$(date) Build completed successfully"
break
fi
if [ "$PHASE" == "Failed" ]; then
echo "$(date -u) uild failed"
echo "$(date) uild failed"
break
fi
echo "$(date -u) Waiting for build to complete...$PHASE"
echo "$(date) Waiting for build to complete...$PHASE"
sleep 1
done

Expand All @@ -51,9 +51,9 @@ sleep 2
# patch kuberoes resource with the new image
kubectl patch --type=merge kuberoapps.application.kubero.dev ${APP} -p "{\"spec\":{\"image\":{\"repository\":\"${REPOSITORY}\",\"tag\":\"${TAG}\"}}}"
if [ $? -ne 0 ]; then
echo "$(date -u) Failed to patch kubero app resource"
echo "$(date) Failed to patch kubero app resource"
exit 1
fi

echo "$(date -u) Successfully patched kubero app resource"
echo "$(date) Successfully patched kubero app resource"
exit 0

0 comments on commit e6f9c95

Please sign in to comment.