[Support Guide] How to use the ignore command

The ignore command is a powerful way for you to control whether or not builds run based on variables of your choosing. Here’s how it works: you can set ignore in your netlify.toml to any Bash command or Bash script. If your ignore command or script exits 0, the build is canceled. If the command or script exits with 1 or any other exit code, the build continues.

We created this feature for monorepo support, but it is useful in other contexts too, like choosing whether to deploy based on the branch name. Below are a handful of examples that cover some of the use cases we see most frequently. They make use of some of our built-in environment variables like:


They also use custom environment variables you might create like $GITHUB_PAT.

Example 1: Simple way to ignore all builds

  ignore = "exit 0"

Example 2: Ignore builds of PRs from tools-netlify bot on netlify/build-image repo

   ignore = "curl https://api.github.com/repos/netlify/build-image/pulls/$REVIEW_ID | grep '\"login\": \"tools-netlify\"'"

Example 3: Ignore builds of PRs on a private repo by calling the GitHub API with a token

   ignore = "curl -H \"Authorization: token $GITHUB_PAT\" --request GET curl https://api.github.com/repos/:owner/:repo/commits/:sha/status | grep '...'"

Example 4: Use a bash script to ignore all builds on branch never-build


  ignore = "bash ./build-ignore.sh"

where build-ignore.sh is:


if [[ $BRANCH == "never-build" ]]
  exit 0
  exit 1

Example 5: Same result as above, but using our branch context and no Bash script


  ignore = "exit 0"

Our default ignore command for monorepo projects

  ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ."

Example 6: Customize our default ignore command to check for changes in dirA/ and dirB/ instead of just current root directory

  ignore = "git diff --quiet $COMMIT_REF $CACHED_COMMIT_REF -- dirA/ dirB/"

If you have questions about your ignore command or have a successful example to share, please create a thread and we’ll take a look!