Skip to content

Commit c096600

Browse files
committed
Add error handling and deployment status output
1 parent 6255b6e commit c096600

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: deploy.sh

+9
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,18 @@ function upgrade_release() {
5252
# The --install flag ensures that the release will be installed if it does not exist
5353
# The --debug flag enables verbose output for debugging
5454
# The --set flag sets the specified values on the command line
55+
trap 'catch_errors' ERR
56+
catch_errors() {
57+
echo "Error occurred during deployment. Rolled back to version: $(helm history app-release --max 1 --output json | jq -r '.[0].app_version')"
58+
exit 1
59+
}
5560
helm upgrade --install --atomic app-release ./my-chart ${set_flag} ${debug_flag}
5661
kubectl rollout status deployment/app-release-my-chart-v1
5762
kubectl rollout status deployment/app-release-my-chart-v2
63+
echo "Current deployment status:"
64+
kubectl get deployments
65+
echo "Current releases history:"
66+
helm history app-release
5867
}
5968

6069
validate_input "${1}"

0 commit comments

Comments
 (0)