Skip to content

Commit

Permalink
ecr-access job: fix slack notification in case of failure
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre committed Mar 14, 2024
1 parent ec6510f commit 5a4c705
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions kube/services/jobs/ecr-access-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,19 @@ spec:
args:
- "-c"
- |
set -e
cd cloud-automation/files/scripts/
echo Installing requirements...
pip3 install -r ecr-access-job-requirements.txt
python3 ecr-access-job.py
exitcode=$?
if [[ "${SLACK_WEBHOOK}" != 'None' ]]; then
if [[ $exitcode == 1 ]]; then
curl -X POST --data-urlencode "payload={\"text\": \"JOBFAIL: ECR access job on ${HOSTNAME}\"}" "${SLACK_WEBHOOK}"
else
if python3 ecr-access-job.py; then
echo "Success - Exit code: $?"
if [[ "${SLACK_WEBHOOK}" != 'None' ]]; then
curl -X POST --data-urlencode "payload={\"text\": \"SUCCESS: ECR access job on ${HOSTNAME}\"}" "${SLACK_WEBHOOK}"
fi
else
exitcode=$?
echo "Failure - Exit code: $exitcode"
if [[ "${SLACK_WEBHOOK}" != 'None' ]]; then
curl -X POST --data-urlencode "payload={\"text\": \"JOBFAIL: ECR access job on ${HOSTNAME}\"}" "${SLACK_WEBHOOK}"
fi
exit $exitcode
fi
echo "Exit code: $exitcode"
exit "$exitcode"

0 comments on commit 5a4c705

Please sign in to comment.