add failure handler

This commit is contained in:
Pim Kunis 2023-05-26 09:28:00 +02:00
parent 7dc508ffb9
commit 3e74f5a84f

View file

@ -1,3 +1,19 @@
---
notify-failed: &notify-failed
task: notify-failed
config:
platform: linux
image_resource:
type: registry-image
source:
repository: badouralix/curl-jq
run:
path: sh
args:
- -exc
- |
curl -X POST -d '{"body":"Deployment failed!"}' -H "Content-Type: application/json" https://apprise.pim.kunis.nl:444/notify/concourse
resources:
- name: site-repo
type: git
@ -38,6 +54,8 @@ jobs:
cd site-repo/jekyll
bundle install
bundle exec jekyll build --disable-disk-cache --destination ../../site-html
on_failure:
<< : *notify-failed
- task: build-image
privileged: true
config:
@ -61,6 +79,8 @@ jobs:
build
ls image
cat image/digest | cut -d ":" -f 2- > image/tag
on_failure:
<< : *notify-failed
- task: get-site-packages
config:
platform: linux
@ -78,6 +98,8 @@ jobs:
ls -lash
curl -X 'GET' 'https://git.pim.kunis.nl/api/v1/packages/pim?type=container&q=static' -H 'accept: application/json' | jq -rc 'map(.version) | .[]' > site-packages/packages.txt
cat site-packages/packages.txt
on_failure:
<< : *notify-failed
- task: delete-old-packages
config:
platform: linux
@ -94,10 +116,14 @@ jobs:
- |
ls -lash
while read pkg; do curl -X 'DELETE' "https://git.pim.kunis.nl/api/v1/packages/pim/container/static/$pkg?token=((api_key))" -H 'accept: application/json'; done < site-packages/packages.txt
on_failure:
<< : *notify-failed
- put: site-registry-image
params:
image: image/image.tar
additional_tags: image/tag
on_failure:
<< : *notify-failed
- load_var: tag
file: image/tag
- task: deploy-site
@ -137,3 +163,5 @@ jobs:
- -exc
- |
curl -X POST -d '{"body":"Static website deployed!"}' -H "Content-Type: application/json" https://apprise.pim.kunis.nl:444/notify/concourse
on_failure:
<< : *notify-failed