Branch deploys do not cancel when code has not changed

Site: xenodochial-lamport-636afb

I have a site that deploys from the base directory web/api-docs for all branches. When I push a branch I expect that this site would cancel any deploy if the code under web/api-docs did not change. However, this is not the case. See for example a recent build for commit 9ae9e43. What do I need to configure for these builds to cancel automatically if the code in the base directory does not change?

Hey @jlhasson

You might find the ignore command useful

Hey, thanks for the reply. I’ve written one of these commands in the past with mixed success, but the article looks updated so I’ll take another look.

One question from the example in the article:

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

This is the default command, which refers to the “root directory” via the dot (.). Why is the root directory in this case not web/api-docs? When I look at the logs from the builds it appears they all take place within this directory, so it’s odd to me that this default ignore script doesn’t also run from this directory.

I would guess that works, because there is intended to be a base directory set on this example :slight_smile:

I’m not sure we will even run your custom ignore command unless you set a build command on your site. I understand that you do not want our CI to build your content, but I think our system may require that for ignore commands to work (versus for the “default” cancellation that we did for instance in this build - before your ignore command ran I think: Netlify App).

To be clear, I don’t have an ignore command set, above I was referencing what the docs describe as the default behavior. But interesting to know that it won’t work without a build command. In this case my site is static so there isn’t anything to build :smiley:

Also, that example you linked is great, and you can see that it behaves correctly sometimes. However there are others where it doesn’t unfortunately. These commits are “equivalent” in the sense that they don’t affect the files in the base directory of this site (web/api-docs). You can see that one built, while the other didn’t. Not sure what causes that behavior.

Could I suggest that you:

git diff $CACHED_COMMIT_REF $COMMIT_REF && echo $?

  • then try a bunch more builds until you can tickle the unexpected behavior.

…that command then, should show you “what that command output, and what it returned”. From there hopefully you’ll be able to find some logic that always returns what you want, and implement it as an ignore command, though it may need a build command too (perhaps you could use /bin/true - which should be a no-op)?