How to stop Netlify building on every push
Netlify has two ways: turn on Stop builds, which stops every build including build hooks, or add an ignore command to netlify.toml that skips every build not started by a build hook. Stop builds is simplest if you deploy from your machine; the ignore command keeps Netlify building, but only when you call the hook.
| What | Stop builds | ignore + build hook |
|---|---|---|
| Git pushes | No build | Cancelled by the ignore command |
| Build hook | No build | Builds |
| How you deploy | netlify deploy --prod from your machine or CI | One POST to the hook URL; Netlify builds |
| Where it is set | Site settings (or API) | netlify.toml in the repository |
1. Stop builds
- Open the site, then Site configuration → Build & deploy → Continuous deployment.
- Under Build settings, choose Configure, then Stop builds, and save.
- Build locally or in CI and upload the result:
netlify build
netlify deploy --prod
The same switch is the stop_builds field in the site's build settings in the Netlify API:
curl -s -X PATCH "https://api.netlify.com/api/v1/sites/$SITE_ID" \
-H "Authorization: Bearer $NETLIFY_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{"build_settings":{"stop_builds":true}}'
Trade-offs. Netlify will not build anything, not even from a build hook, so deploy previews stop too. You build on your own machine or in CI.
2. An ignore command that only lets build hooks through
Netlify runs the ignore command before each build: exit 0 cancels, exit 1 builds. For builds started by a build hook, Netlify sets INCOMING_HOOK_TITLE (and INCOMING_HOOK_URL, INCOMING_HOOK_BODY); for pushes it is empty. So this skips everything except hook builds:
# netlify.toml
[build]
ignore = 'test -z "$INCOMING_HOOK_TITLE"'
test -z exits 0 when the variable is empty (a push: skip) and 1 when it is set (a hook: build). Single quotes make it a literal TOML string, so the double quotes reach the shell unchanged.
- Create a hook: Site configuration → Build & deploy → Continuous deployment → Build hooks → Add build hook. Pick the branch to build.
- Commit the
netlify.tomlabove. That push is the last one that builds by itself. - Deploy when you want:
curl -s -X POST -d '{}' "https://api.netlify.com/build_hooks/$HOOK_ID"
Trade-offs. Each push still shows up as a cancelled deploy. A deploy started with Trigger deploy in the Netlify UI has no hook title, so this rule cancels it too; use the hook. Deploy previews for pull requests are skipped as well. The hook URL is a secret: anyone with it can start a build.
Only some branches
To keep deploy previews and only stop production builds from pushes, check the context Netlify sets in CONTEXT:
[build]
ignore = '[ "$CONTEXT" = production ] && [ -z "$INCOMING_HOOK_TITLE" ]'
Netlify in Deploy Center
Deploy Center supports Netlify as an opt-in host, built on the build hook approach above. Turn it on with deploys providers enable netlify, store a personal access token with deploys netlify set-key, then run deploys netlify autodeploy-off <site>: it creates a build hook named deploy-center and prints the ignore line for netlify.toml. Deploy Center accepts the rule ignore = "[ -z \"$INCOMING_HOOK_TITLE\" ]", which skips every build a build hook did not start. Setup, limits and what it cannot do: the Netlify provider docs.
Questions
What is the difference between Stop builds and the ignore command?
Stop builds stops every build, build hooks included; you deploy by uploading a build with the CLI. The ignore command cancels the builds it rejects, so you can still let build hook builds through.
Which exit code skips a Netlify build?
Exit code 0 cancels the build. Exit code 1 lets it run.
How do I know a build came from a build hook?
Netlify sets INCOMING_HOOK_TITLE, INCOMING_HOOK_URL and INCOMING_HOOK_BODY for builds triggered by a build hook. For a push they are empty.
Does Deploy Center support Netlify?
Yes, as an opt-in host: deploys providers enable netlify. It uses a build hook and an ignore rule in netlify.toml, so a push builds nothing and a deploy from Deploy Center goes through.
Use Vercel or Render too?
Deploy Center turns off auto-deploy on Vercel and Render in one click, Netlify and other hosts opt-in, and deploys what changed when you decide. Free and open source for macOS.