now we have both failure and success messages

This commit is contained in:
Pablo Martin 2024-05-30 16:38:39 +02:00
parent b1aa29b228
commit 77b4a8264c

View file

@ -1,17 +1,18 @@
#!/bin/bash
# Define the Slack webhook URL and message text
# Define the Slack webhook URL
script_dir=$(dirname "$0")
env_file="$script_dir/slack_webhook_urls.txt"
webhooks_file="slack_webhook_urls.txt"
env_file="$script_dir/$webhooks_file"
if [ -f "$env_file" ]; then
export $(grep -v '^#' "$env_file" | xargs)
else
echo "Error: slack_webhook_urls.txt file not found in the script directory."
echo "Error: $webhooks_file file not found in the script directory."
exit 1
fi
# Messages to be sent to Slack
slack_failure_message=":siren::siren::siren: One or more failures during scheduled dbt run in production. :siren::siren::siren:"
slack_failure_message=":rotating_light::rotating_light::rotating_light: One or more failures during scheduled dbt run in production. :rotating_light::rotating_light::rotating_light:"
slack_success_message=":white_check_mark::white_check_mark::white_check_mark: dbt run executed successfully in production. :white_check_mark::white_check_mark::white_check_mark:"
# Initialize the failure flag
@ -57,7 +58,8 @@ fi
# Check if any step failed and send a Slack message
if [ $has_any_step_failed -eq 1 ]; then
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_failure_message\"}" $SLACK_WEBHOOK_URL
else
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_success_message\"}" $SLACK_WEBHOOK_URL
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_failure_message\"}" $SLACK_ALERT_WEBHOOK_URL
fi
if [ $has_any_step_failed -eq 0 ]; then
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_success_message\"}" $SLACK_RECEIPT_WEBHOOK_URL
fi