Build: OnSuccess, OnError, and OnEnd don't work in tandem with our open API

Created on 17 May 2020  路  7Comments  路  Source: netlify/build

Steps to Reproduction

  • Create a build plugin which uses the netlify package
  • Use constants to gather the SITE_ID and pass to the API
  • Use one of the following build hooks: onSuccess, onError, onEnd and log the last deploy from client.listSiteDeploys
  • values are null

Expected behavior

I would expect to have access to information about the build as it finishes.

Bronze medal

If I don't and can't have access, we should be explicit in the docs that this is the case.

Silver medal

Ensure the API can work with the final hooks or provide one more hook where it does resolve.

Gold medal

Make some more of this information available to me in constants so I don't need the netlify package. Apologies if this exists already but if it does, I didn't find it :)

In the plugin js file

let siteDeploys = await client.listSiteDeploys({
  site_id: constants.SITE_ID,
})

siteDeploys = siteDeploys.map(({ screenshot_url, published_at }) => ({
  screenshot_url,
  published_at,
}))

console.log(`deploys: ${JSON.stringify(siteDeploys, null, 2)}`)

Output

9:49:35 AM: deploys: [
9:49:35 AM:   {
9:49:35 AM:     "screenshot_url": null,
9:49:35 AM:     "published_at": null
9:49:35 AM:   },
9:49:35 AM:   {
9:49:35 AM:     "screenshot_url": "https://353a23c500dde3b2ad58-c49fe7e7355d384845270f4a7a0a7aa1.ssl.cf2.rackcdn.com/5ec15b8c0f20eb0007ef7311/screenshot.png",
9:49:35 AM:     "published_at": "2020-05-17T15:44:24.753Z"
9:49:35 AM:   },
9:49:35 AM:   {
9:49:35 AM:     "screenshot_url": "https://353a23c500dde3b2ad58-c49fe7e7355d384845270f4a7a0a7aa1.ssl.cf2.rackcdn.com/5ec15a8639440a0007a8cb20/screenshot.png",
9:49:35 AM:     "published_at": "2020-05-17T15:39:41.930Z"
9:49:35 AM:   },

Let me know what direction you want to go here, I'm happy to help.

feature

All 7 comments

Hi @sdras, thanks for suggesting this.

Currently Build plugins (including onEnd, onError and onSuccess) end before deploys start. The following issues are discussing adding an onPostDeploy hook: https://github.com/netlify/buildbot/issues/550, https://github.com/netlify/buildbot/issues/640.

Thank you so much for the added color, that's extremely valuable! It's unclear from these issues where the conversation landed because so much happened in meetings. What's the best way to follow up from here?

Also, open to me opening a PR to explain this in the readme in the interim? Thanks @ehmicky!

I think @erquhart has been leading those conversation, so might have more information on their current status.
About the PR: yes, absolutely!

As far as I'm aware, we have ideas on how to move forward with post deploy hooks, but we're not executing on it at the moment.

We have some ongoing work described in https://github.com/netlify/buildbot/issues/640, https://github.com/netlify/buildbot/issues/550, https://github.com/netlify/pod-the-builder/issues/42, https://github.com/netlify/pod-the-builder/issues/48, https://github.com/netlify/pod-the-builder/issues/45. It seems to me those issues should capture everything from this issue, so I am closing it. However, if you think something might be missing, please re-open this issue. Thanks!

Thank you @ehmicky!

Was this page helpful?
0 / 5 - 0 ratings