News & Announcements
Post-deploy Events Now Available to Build Plugins
Build Plugins enable you to "plug in" to different event stages in the build-deploy lifecycle, running custom automated tasks right at the time when they're needed. This week, we're excited to announce an expansion of those capabilities.
Until recently, Build Plugin event handlers were limited to the "build" portion of the lifecycle, ranging from just before the build command, with onPreBuild
, to just before deploying site assets, with onPostBuild
.
But many customers and plugin authors have wanted their plugins to access the site after it's gone live. Now, we have two events for that purpose:
onSuccess
runs after a successful site deploy. This matches the timing of "Deploy succeeded" notifications and webhooks.onEnd
runs at the very end of the build-deploy lifecycle, regardless of whether the deploy succeeded or failed.
Note that because the site has already been deployed live (or failed) by the time an onSuccess
or onEnd
event runs, plugins can't use that event to fail the build/deploy. However, they can report errors or failures back to the deploy summary to recommend changes for the next deploy.
Post-deploy event handlers open up a variety of powerful new plugin capabilities, including:
- Crawling live deploy URLs. Algolia has been using a special preview version of
onSuccess
to generate site search indexes with their Algolia Crawler plugin. - Running performance audits. Several plugins use services like SpeedCurve, PerfBeacon, PageWatch, Dareboost, and DebugBear to generate Lighthouse scores and compare metrics between deploys.
- Sending timely deploy data. The submit sitemap plugin uses
onSuccess
to send a fresh sitemap to search engines as soon as the deploy is live, and not a minute sooner. - Testing Netlify Functions responses. Functions aren't available until they're deployed, so post-deploy events now enable functions testing right in your build. We're happy to send updates to the customers who requested this!
- Quicker access to Deploy Previews. Some tests don't need to fail the build. By moving them post-deploy, you can check your preview sooner, and let the tests keep running in the background.
Try it yourself
You can take advantage of this new post-deploy functionality by installing one of the plugins mentioned above or another from the plugins directory.
Or you can make your own plugin! Check out the docs to learn how.
As you work with Netlify Build Plugins, we'd love to find out more about how you're using them and what features you'd like to have in the future. (Perhaps an onPreInstall
event handler?) We're always happy to chat in the Community Forums.