Reputation: 1889
I have several automated builds set up on docker hub. I see that I can set up a webhook to POST to a URL on a successful build, but it seems like it's more useful to be notified of a failed build. Is there any way to do that?
I tried adding a webhook and then pushing a deliberately bad RUN instruction to my Dockerfile. The automated build failed as expected but nothing was sent to my webhook.
Some of my builds are triggered not by git pushes but by cron jobs, so even if I tested the build before every commit, it wouldn't catch this situation. Builds that are successful one day could fail the next due to changing contents of URLs downloaded via ADD.
So...is there a way to get a notification of a failed automated build? If not, consider this a feature request.
Upvotes: 5
Views: 1086
Reputation: 23
One option is to poll Docker Hub v2 API and emulate the missing notifications whenever the build history reports a failure (-1) or the build remains queued for too long. The solution is described here: Docker on-failure Webhook and is based on the Axibase Time Series Database sandbox image.
docker run -d -p 8443:8443 -p 9443:9443 \
--name=atsd-sandbox \
--env NAMESPACE='google' \
--env NOTIFY_URL='https://webhook.site/71fd9feb-8751-4afd-9e13-16072a34b259' \
--env ATSD_IMPORT_PATH='https://raw.githubusercontent.com/axibase/atsd-use-cases/master/how-to/docker/resources/notify.xml,https://raw.githubusercontent.com/axibase/atsd-use-cases/master/how-to/docker/resources/rule.xml' \
--env COLLECTOR_IMPORT_PATH='https://raw.githubusercontent.com/axibase/atsd-use-cases/master/how-to/docker/resources/job.xml' \
axibase/atsd-sandbox:latest
If the build fails intermittently, you can even program the rule to 'retaliate' against Docker Hub by initiating a retry using remote triggers.
Disclaimer: I work for Axibase.
Upvotes: 0
Reputation: 12677
You can turn on email-based notifications that a build has failed by going under your user settings option and clicking on notifications and checking the appropriate box. (Thanks @docker twitter account; this wasn't obvious to me either! https://twitter.com/DockerSupport/status/555912171792527360 )
As you have observed, a webhook for a POST event is not available for failed builds. I imagine the idea is that these are more for triggering some follow-up event such as telling a machine to pull the new image, while an email notification makes more sense for a failed build.
Upvotes: 3