|
|
|
|
@ -159,133 +159,6 @@ jobs:
|
|
|
|
|
make -C testing/dbtest/docker clean
|
|
|
|
|
name: Cleanup
|
|
|
|
|
when: always
|
|
|
|
|
- run:
|
|
|
|
|
command: |
|
|
|
|
|
echo 'export SLACK_BUILD_STATUS="fail"' >> $BASH_ENV
|
|
|
|
|
name: Slack - Setting Failure Condition
|
|
|
|
|
when: on_fail
|
|
|
|
|
- run:
|
|
|
|
|
command: |
|
|
|
|
|
echo 'export SLACK_BUILD_STATUS="success"' >> $BASH_ENV
|
|
|
|
|
name: Slack - Setting Success Condition
|
|
|
|
|
when: on_success
|
|
|
|
|
- run:
|
|
|
|
|
command: |
|
|
|
|
|
if [ ! -x /bin/bash ]; then
|
|
|
|
|
echo Bash not installed.
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
name: Provide error if non-bash shell
|
|
|
|
|
- run:
|
|
|
|
|
command: |
|
|
|
|
|
current_branch_in_filter=false
|
|
|
|
|
|
|
|
|
|
IFS="," read -ra BRANCH_FILTERS <<< "master"
|
|
|
|
|
|
|
|
|
|
for i in "${BRANCH_FILTERS[@]}"; do
|
|
|
|
|
if [ "${i}" == "${CIRCLE_BRANCH}" ]; then
|
|
|
|
|
current_branch_in_filter=true
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ "x" == "xmaster" ] || [ "$current_branch_in_filter" = true ]; then
|
|
|
|
|
# Provide error if no webhook is set and error. Otherwise continue
|
|
|
|
|
if [ -z "webhook" ]; then
|
|
|
|
|
echo "NO SLACK WEBHOOK SET"
|
|
|
|
|
echo "Please input your SLACK_WEBHOOK value either in the settings for this project, or as a parameter for this orb."
|
|
|
|
|
exit 1
|
|
|
|
|
else
|
|
|
|
|
#Create Members string
|
|
|
|
|
if [ -n "" ]; then
|
|
|
|
|
IFS="," read -ra SLACK_MEMBERS <<< ""
|
|
|
|
|
for i in "${SLACK_MEMBERS[@]}"; do
|
|
|
|
|
if [ $(echo ${i} | head -c 1) == "S" ]; then
|
|
|
|
|
SLACK_MENTIONS="${SLACK_MENTIONS}<!subteam^${i}> "
|
|
|
|
|
elif echo ${i} | grep -E "^(here|channel|everyone)$" > /dev/null; then
|
|
|
|
|
SLACK_MENTIONS="${SLACK_MENTIONS}<!${i}> "
|
|
|
|
|
else
|
|
|
|
|
SLACK_MENTIONS="${SLACK_MENTIONS}<@${i}> "
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
#If successful
|
|
|
|
|
if [ "$SLACK_BUILD_STATUS" = "success" ]; then
|
|
|
|
|
#Skip if fail_only
|
|
|
|
|
if [ true = true ]; then
|
|
|
|
|
echo "The job completed successfully"
|
|
|
|
|
echo '"fail_only" is set to "true". No Slack notification sent.'
|
|
|
|
|
else
|
|
|
|
|
curl -X POST -H 'Content-type: application/json' \
|
|
|
|
|
--data "{ \
|
|
|
|
|
\"attachments\": [ \
|
|
|
|
|
{ \
|
|
|
|
|
\"fallback\": \":tada: A $CIRCLE_JOB job has succeeded!\", \
|
|
|
|
|
\"text\": \":tada: A $CIRCLE_JOB job has succeeded! $SLACK_MENTIONS\", \
|
|
|
|
|
\"fields\": [ \
|
|
|
|
|
{ \
|
|
|
|
|
\"title\": \"Project\", \
|
|
|
|
|
\"value\": \"$CIRCLE_PROJECT_REPONAME\", \
|
|
|
|
|
\"short\": true \
|
|
|
|
|
}, \
|
|
|
|
|
{ \
|
|
|
|
|
\"title\": \"Job Number\", \
|
|
|
|
|
\"value\": \"$CIRCLE_BUILD_NUM\", \
|
|
|
|
|
\"short\": true \
|
|
|
|
|
} \
|
|
|
|
|
], \
|
|
|
|
|
\"actions\": [ \
|
|
|
|
|
{ \
|
|
|
|
|
\"type\": \"button\", \
|
|
|
|
|
\"text\": \"Visit Job\", \
|
|
|
|
|
\"url\": \"$CIRCLE_BUILD_URL\" \
|
|
|
|
|
} \
|
|
|
|
|
], \
|
|
|
|
|
\"color\": \"#1CBF43\" \
|
|
|
|
|
} \
|
|
|
|
|
] \
|
|
|
|
|
} " webhook
|
|
|
|
|
echo "Job completed successfully. Alert sent."
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
#If Failed
|
|
|
|
|
curl -X POST -H 'Content-type: application/json' \
|
|
|
|
|
--data "{ \
|
|
|
|
|
\"attachments\": [ \
|
|
|
|
|
{ \
|
|
|
|
|
\"fallback\": \":red_circle: A $CIRCLE_JOB job has failed!\", \
|
|
|
|
|
\"text\": \":red_circle: A $CIRCLE_JOB job has failed! $SLACK_MENTIONS\", \
|
|
|
|
|
\"fields\": [ \
|
|
|
|
|
{ \
|
|
|
|
|
\"title\": \"Project\", \
|
|
|
|
|
\"value\": \"$CIRCLE_PROJECT_REPONAME\", \
|
|
|
|
|
\"short\": true \
|
|
|
|
|
}, \
|
|
|
|
|
{ \
|
|
|
|
|
\"title\": \"Job Number\", \
|
|
|
|
|
\"value\": \"$CIRCLE_BUILD_NUM\", \
|
|
|
|
|
\"short\": true \
|
|
|
|
|
} \
|
|
|
|
|
], \
|
|
|
|
|
\"actions\": [ \
|
|
|
|
|
{ \
|
|
|
|
|
\"type\": \"button\", \
|
|
|
|
|
\"text\": \"Visit Job\", \
|
|
|
|
|
\"url\": \"$CIRCLE_BUILD_URL\" \
|
|
|
|
|
} \
|
|
|
|
|
], \
|
|
|
|
|
\"color\": \"#ed5c5c\" \
|
|
|
|
|
} \
|
|
|
|
|
] \
|
|
|
|
|
} " webhook
|
|
|
|
|
echo "Job failed. Alert sent."
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo "Current branch is not included in only_for_branches filter; no status alert will be sent"
|
|
|
|
|
fi
|
|
|
|
|
name: Slack - Sending Status Alert
|
|
|
|
|
shell: /bin/bash
|
|
|
|
|
when: always
|
|
|
|
|
test-sql-latest:
|
|
|
|
|
machine:
|
|
|
|
|
image: ubuntu-2004:202111-01
|
|
|
|
|
@ -376,10 +249,6 @@ workflows:
|
|
|
|
|
# make -C testing/dbtest/docker clean
|
|
|
|
|
# name: Cleanup
|
|
|
|
|
# when: always
|
|
|
|
|
# - slack/status:
|
|
|
|
|
# fail_only: true
|
|
|
|
|
# only_for_branches: master
|
|
|
|
|
# webhook: webhook
|
|
|
|
|
# make-gen-deltas:
|
|
|
|
|
# executor: go-machine-medium
|
|
|
|
|
# steps:
|
|
|
|
|
|