now we have both failure and success messages
This commit is contained in:
parent
b1aa29b228
commit
77b4a8264c
1 changed files with 9 additions and 7 deletions
16
run_dbt.sh
16
run_dbt.sh
|
|
@ -1,17 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Define the Slack webhook URL and message text
|
# Define the Slack webhook URL
|
||||||
script_dir=$(dirname "$0")
|
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
|
if [ -f "$env_file" ]; then
|
||||||
export $(grep -v '^#' "$env_file" | xargs)
|
export $(grep -v '^#' "$env_file" | xargs)
|
||||||
else
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Messages to be sent to Slack
|
# 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:"
|
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
|
# Initialize the failure flag
|
||||||
|
|
@ -57,7 +58,8 @@ fi
|
||||||
|
|
||||||
# Check if any step failed and send a Slack message
|
# Check if any step failed and send a Slack message
|
||||||
if [ $has_any_step_failed -eq 1 ]; then
|
if [ $has_any_step_failed -eq 1 ]; then
|
||||||
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_failure_message\"}" $SLACK_WEBHOOK_URL
|
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_failure_message\"}" $SLACK_ALERT_WEBHOOK_URL
|
||||||
else
|
fi
|
||||||
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_success_message\"}" $SLACK_WEBHOOK_URL
|
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
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue