Ignore build doesn't work on a exit code 1 immediately following a deploy

Hey team :slight_smile:

I’m using an ignore build command in conjunction with a custom base directory.

I’ve followed the example given, and have tested it locally. It does provide the correct exit codes locally. However, in practice, it seems to build the deploy following a change as well. Testing the diff on the commit hashes locally, I still get a 0 exit code.


Link to the monorepo: GitHub - deepgram/web-next
Link to the application: Netlify App
Link to the base directory of the application: web-next/www at main · deepgram/web-next · GitHub
Link to the latest build in the screenshot: Netlify App
Link to the most recent false positive build: Netlify App

Let me know if any other details will help

Hey @lukeoliff,

Could you try to run your ignore command without --quiet (and with an && echo $? appended, to show exit status), as your build command instead, to see what it outputs?

Hi, @lukeoliff. The repo is public which has made this much easier to troubleshoot and I thank you for asking about a public repo.

I took a look at this cancelled build:


The trick here is that the CACHED_COMMIT_REF environment variable is based on the build cache for the same context. That was a production build for the branch main so I looked for the previous successful build of that same branch. That is the build below:


Each deploy details page above contains a link to the commit that triggered this build. The two commits are these:

Cached: https://github.com/lukeocodes/web-next/commit/add27b9be475367a4a9546706995397261da9a31
Current (for the cancelled build): https://github.com/lukeocodes/web-next/commit/9f25ae3e356acf9f52a247e8ccee64c114288a01

Finally, the “base directory” is www here:


So, using that information above I was able to check the build ignore command like so:

$ git clone https://github.com/deepgram/web-next
Cloning into 'web-next'...
remote: Enumerating objects: 835, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (139/139), done.
remote: Total 835 (delta 46), reused 111 (delta 25), pack-reused 628
Receiving objects: 100% (835/835), 3.00 MiB | 13.64 MiB/s, done.
Resolving deltas: 100% (240/240), done.
$ cd web-next/www
$ git diff --quiet add27b9be475367a4a9546706995397261da9a31 9f25ae3e356acf9f52a247e8ccee64c114288a01 ../content/www/ ./ ; echo $?
$ git diff add27b9be475367a4a9546706995397261da9a31 9f25ae3e356acf9f52a247e8ccee64c114288a01 ../content/www/ ./

I ran the build ignore twice above (with and without the --quiet option). The first shows that the exit code is zero (no diff). The second show again that no diff output exists. There is no different in those directory trees between those two commits.

Now, there could be errors happening elsewhere in other build. However, for that build above, the build ignore command did function correctly.

EDIT (added content below):

I also ran the non-quiet diff for those two commits in the base of the repo to see where the diff does exist:

$ git diff add27b9be475367a4a9546706995397261da9a31 9f25ae3e356acf9f52a247e8ccee64c114288a01 .
diff --git a/cms/config.yml b/cms/config.yml
index e370118..c5dddce 100644
--- a/cms/config.yml
+++ b/cms/config.yml
@@ -100,15 +100,15 @@ collections:
             required: false
   - name: pages
     label: "Marketing Pages"
-    summary: "({{filename}}) {{title}}"
+    summary: "(/{{dirname}}) {{title}}"
     label_singular: Page
     folder: "content/www/pages"
     path: "{{slug}}"
     create: true
-      depth: 100 # max depth to show in the collection tree
+      depth: 3 # max depth to show in the collection tree
       summary: "{{title}}" # optional summary for a tree node, defaults to the inferred title field
-    meta: { path: { widget: string, label: "Path", index_file: "index" } }
+    meta: { path: { label: Parent, widget: parent, index_file: "index" } }
     slug: "{{slug}}"
       - label: Title
diff --git a/cms/index.html b/cms/index.html
index 184768e..384474c 100644
--- a/cms/index.html
+++ b/cms/index.html
@@ -10,7 +10,12 @@
     <!-- Include the script that builds the page and powers Netlify CMS -->
     <script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
+    <script src="https://unpkg.com/@netlify/netlify-cms-widget-parent@^1.0.0/dist/netlify-cms-widget-parent.js"></script>
+      const parentWidget = window.NetlifyCmsWidgetParent;
+      CMS.registerWidget("parent", parentWidget.control, parentWidget.preview);
       // YouTube custom editor component.
         // Internal id of the component

This shows the changes are in both under the cms directory which isn’t checked by the custom build ignore command below:

git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../content/www/ ./

Because that is being run in the base directory of www it only watches www and content/www. Any changes in cms are ignored by the command above and will not be detected.