Ignore in monorepo always ignores

I’ve read just about every build ignore configuration thread on here but unfortunately, nothing worked, so I’m opening this.

We have a monorepo that our site “unruffled-benz-43c2e1” is deployed from.

Our netlify.toml looks like this:

 cat netlify.toml 
[build]
  base = "ui/packages/app/website"
  ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ."
  command = "yarn && yarn run build"
  publish = "out"

Previews appear to work, but whenever we merge a PR into the repo then builds are always canceled, supposedly because they are being ignored. Here’s a build output:

2:40:05 PM: Build ready to start
2:40:16 PM: build-image version: 6c366b9e0cc38bb3f3a40b7951f398b33cac286d
2:40:16 PM: build-image tag: v3.8.1
2:40:16 PM: buildbot version: d6f7e5fc881fb3682c2d42eb968d84e9b04dfca0
2:40:16 PM: Fetching cached dependencies
2:40:16 PM: Failed to fetch cache, continuing with build
2:40:16 PM: Starting to prepare the repo for build
2:40:17 PM: No cached dependencies found. Cloning fresh repo
2:40:17 PM: git clone <redacted>
2:40:20 PM: Preparing Git Reference refs/heads/main
2:40:21 PM: Parsing package.json dependencies
2:40:21 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: 'ui/packages/app/website' versus '' in the Netlify UI
2:40:21 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'ui/packages/app/website/out' versus '' in the Netlify UI
2:40:21 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'yarn && yarn run build' versus '' in the Netlify UI
2:40:21 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF .'
2:40:21 PM: User-specified ignore command returned exit code 0. Returning early from build.
2:40:21 PM: Creating deploy upload records
2:40:22 PM: Failed during stage 'checking build content for changes': Canceled build due to no content change
2:40:22 PM: Finished processing build request in 5.600399345s

Side note: it’s really hard to understand what the value of CACHED_COMMIT_REF is, it would be great if there was a way to inspect the value (build command doesn’t work because the build is canceled before it gets to that point).

Hi, @brancz. Personally t adding logging to the build ignore command itself but … that won’t work because all output of that command is suppressed.

You can see the value by appending the command env with two ampersands to your build command like so:

  command = "env && yarn && yarn run build"

However, this would mean that disabling the build ignore command would necessary, temporarily, for troubleshooting.

Would you be willing to make this change and test removing the build.ignore to see what is getting logged?

If that doesn’t help or if there are other questions about this, please let us know.

Done that. It does appear to print the expected commits in the COMMIT_REF and CACHED_COMMIT_REF values.

Hi, @brancz. What is the exit code for this command run in the base of the local repo directory (replacing $CACHED_COMMIT_REF and $COMMIT_REF with the actual hashes for those commits)?

git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ui/packages/app/website ; echo $?

The ; echo $? prints the exit code of the git diff command. If the exit code is 0, then that explains why the build is ignored. The zero means “no difference” and so the zero exit code will stop the build.

If you are getting a non-zero exit code or if there are other questions, please reply here anytime and we will keep troubleshooting.