Custom build ignore script exit code bug

I am trying to understand and use Netlify’s monorepo support. I cannot produce the build.ignore behavior described in the docs:

An exit-code of 0 indicates that the build should return early.

I’ve setup a PR on my repo to test this with the simplest script possible: exit 0. Here is a snippet from the logs, where you can see that the build continues after running the build.ignore command.

6:35:13 AM: Found Netlify configuration file. Overriding site configuration
6:35:13 AM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'exit 0'
6:35:13 AM: Starting build script

Netlify instance names: trainervision.netlify.com and trainervision-amy.netlify.com

I think the exit 0 is exiting the sub-shell and that is why it isn’t working. Would you try making a script which does this instead of running exit 0 directly? For example:

#!/bin/bash

exit 0

This might be saved to a file named exit-zero.sh (with a chmod permission of 700). The build.ignore command would then be the filename “exit-zero.sh” instead.

If this doesn’t work as expected, please let us know.

I’m still seeing the behavior with the exit-zero.sh script change:

11:24:13 AM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'exit-zero.sh'
11:24:13 AM: Starting build script

Here’s the link to the full build log for that site (trainervision-amy.netlify.com): https://app.netlify.com/sites/trainervision-amy/deploys/5de53aa1aba2ad00083d981d

Also, the other project I’m trying to deploy from this directory (trainervision.netlify.com) is also ignoring the ignore script, but in that case there is no reference of “ignore” anywhere in the logs at all. I bring up the other project because in my PR, I added the script in both the root directory and the subproject directory to see if it either project deployed correctly. Neither did. I’ve also un-linked/re-linked both projects to the GitHub repo.

@hkgumbs, I did some testing and I can reproduce this behavior if the path to the build.ignore script doesn’t match the filesystem location.

I found two root causes:

  • If the path to the command/script in build.ignore is invalid, the build continues silently assuming a build should continue.
  • If running a script (and not a command like git diff), the script must be referenced relative to the base directory of the repo (or, possibly, the build directory - I didn’t test that edge case).

So, instead of this:

  ignore = "exit-zero.sh"

Try this instead:

  ignore = "./exit-zero.sh"

I’ll be filing an issue to about this first root cause above and, instead, have the build system log when there is missing/invalid path for build.ignore. I’ll update this topic once more when this issue is filed.

The second root cause isn’t is a bug, technically. It’s default behavior in a bash shell, but I also believe we should have better documentation about this syntax requirement for scripts in our docs.

So, I have two issues to file and I follow-up here again to let you know when that is done (and to cross-link this topic with the issues).

In the meantime, would you please test adding “./” before any script reference and double-check the path to the script is correct? If that doesn’t solve the issue, please let us know.

I filed this issue to get the build-image’s behavior changed regarding missing scripts/commands:

We’ll update this topic again if/when that issue is resolved.

Thanks Luke, that worked for the subdirectory site! I’m still having trouble getting the main site (trainervision) to notice the build.ignore flag. I’ve relinked the site to my GitHub repo, but I suspect it’s still not using the new setup. Can you see on your side whether trainervision.netlify.com is setup to support build.ignore? Here’s what I see in the logs where the ignore check typically is:

12:47:21 PM: Preparing Git Reference pull/5/head
12:47:22 PM: Found netlify.toml. Overriding site configuration
12:47:22 PM: Starting build script

https://app.netlify.com/sites/trainervision/deploys/5dea9412c4945c0008f70ef8