Docker Community Forums

Share and learn in the Docker community.

Docker Hub Webhook on build failure


(Jared Forsyth) #1

I’m trying to use docker hub as part of a CD solution, and it’s frustrating that webhooks are only fired on success. If a build fails, there is no way of knowing. My current thinking is to do some hack with polling the build page and scraping the html, but that’s gross.

Are there any plans for this, or for an API to query build status at least?

Thanks for all the amazing work!


(Scott Johnston) #2

@kencochrane @justen … Can you weigh-in here?


(Andy Rothfusz) #3

You can get an email when a build fails. Not as API-friendly as a webhook, but its something. You should find the setting here https://registry.hub.docker.com/account/notifications/


(Jared Forsyth) #4

Hmmm yeah. Any plans for a webhook? Or is there a repo that I can PR?


(Andy Rothfusz) #5

There’s no repo – the automated build system and surrounding code are not open source, sorry. There is a feature request for a webhook (ST-1752), but I don’t know when or if it will be implemented.


(Ken Cochrane) #6

@jaredly Like @rufus said we have email notifications right now, and that is all that is currently supported. There are plans to add webhooks, as well as other notifications (IRC, slack, etc) types in the future.

Can you let us know what you would like to see in the payload for the webhook, and any other requirements you might have, and then we can add it to our notes.


(Jared Forsyth) #7

Desired fields:

  • build status
  • size of final image (if success)
  • build duration
  • url to a log dump if too large, otherwise the text of the build log
  • if failure, which instruction did it fail on?

Also useful to have (but more work)

  • listing of dockerfile instructions w/ individual durations + log outputs

(Ken Cochrane) #8

ok thanks, I’ll add to our notes. If you think of anything else, please let us know.


(Amine Mouafik) #9

Is this gonna be implemented? That’s kinda required to use Docker Hub in a pipeline.


(Tristan Carel) #10

Hello @kencochrane1 ,
Can you please provide an ETA for this one?

Regards


(Henrik Jonsson) #11

+1 for this feature.

We’ve gotten most of the way through migrating to the public Hub for our images when I noticed that the webhooks only were sent for successful builds.

Since we run tests as part of our Dockerfile, the automatic builds in our private repos is fully sufficient as a CI system, when we run a little service to receive the webhook and post to Slack (this also makes the path to CD an easier option, once we’re ready to say that “image builds” equates to “service can be deployed”).

Having to tell developers to “just look at Slack” for the status of the build and their Docker images would be an significantly easier than “look at Slack for success messages, and go check this separate email list for failure messages”.


(Joseph Heck) #12

How do you get to this link via UI, or is it API only?

When I’m logged into the hub and then access that URI, it redirects me to the hub front page. I’ve got an organization setup, we’re having docker builds failing, and no notifications - can’t seem to drive to a UI element that lets me configure relevant notifications.

@rufus Can you point me to where it can be done?


(Menzo) #13

Hello @hkjn and @jaredly ,

You can use zapier.com to achieve your goal while you wait for this feature to be implemented.

What you need to do in Zapier is create a new “Zap”, and select either “Email by Zapier” or “Email parser by Zapier” as trigger. If you choose the parser, you can try to extract some data from the email like project name and failed build URL.

It will generate a email adres for you, any incoming mails on that email adres will trigger any action you specify ( for example: send message to slack channel. )

Now in your mail box you need to create a auto forwarder that forwards any emails from "no-reply@notify.docker.com" and contains title “There’s been an issue with your automated build” and in the body your project name. You forward these emails to the email you got from Zap, and your action will be triggered. Creating a filter like this is easy in Gmail.

The solution is a bit hacky, but I just tested it and it works perfect. :slight_smile:


(Sergeirodionov) #14

One of the options is to poll Docker Hub v2 API and emulate the missing webhook 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. If the build fails intermittently, you can retaliate against Docker Hub by initiating a retry using remote triggers.