Any way to ignore the ignore clause to trigger builds/redeploys?

https://answers.netlify.com/t/support-guide-how-to-use-the-ignore-command/37517
https://docs.netlify.com/configure-builds/common-configurations/ignore-builds/#custom-ignore-command

We are moving towards a monorepo structure and site deployment setup.

Is there any way to trigger a redeploy other than using build webhook as noted in the Netlify docs?

The Retry deploy: “deploy site” and “clear cache and deploy site” in the Netlify Web GUI don’t seem to override.

A possible use case: a changed ENV variable and new deploy needed.

Out current ignore statement format:
git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../common/

Hey!

Webhook, or API – they’re gonna be the alternatives to the UI @moop-moop!

If these are a no go, could you elaborate on “don’t seem to override”? I’m assuming you mean that the changed env var isn’t picked up?

Doesn’t seem to override meaning, even with clear cache and deploy site, the build is cancelled if there are no site “code” changes.

1:03:30 PM: Build ready to start
1:11:12 PM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
1:11:12 PM: build-image tag: v3.8.0
1:11:12 PM: buildbot version: cfefda0a665468fabfafc38698dc693541f06929
1:11:12 PM: Building without cache
1:11:12 PM: Starting to prepare the repo for build
1:11:13 PM: No cached dependencies found. Cloning fresh repo
1:11:13 PM: git clone https://github.com/***/website
1:11:14 PM: Preparing Git Reference refs/heads/develop
1:11:15 PM: Parsing package.json dependencies
1:11:15 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'packages/***/out' versus 'out' in the Netlify UI
1:11:15 PM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'packages/***/serverless' versus '' in the Netlify UI
1:11:15 PM: Different build command detected, going to use the one specified in the Netlify configuration file: 'yarn --cwd ../../common/***/ postinstall && yarn build' versus '' in the Netlify UI
1:11:15 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../common/'
1:11:15 PM: User-specified ignore command returned exit code 0. Returning early from build.
1:11:15 PM: Creating deploy upload records
1:11:15 PM: Failed during stage 'checking build content for changes': Canceled build due to no content change
1:11:15 PM: Finished processing build request in 3.113492805s

Hey @moop-moop,
I don’t know of a way to override the ignore command, but one way you could handle the env var changes is have a boolean like ENV_CHANGE, and check for the value in your ignore script. So something like this (caveat: writing Bash is… not my expertise!):

#!/bin/bash

if [[ $ENV_CHANGE = true ]]
then
  exit 1
elif [[ git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../../common/ ]]
then
  exit 0
else
  exit 1
fi

The added overhead here is that you have to remember to switch variable’s value when you make a relevant change. You may be able to adapt other examples from here: [Support Guide] How to use the ignore command

1 Like

Thanks! I overlooked that approach and the flexibility of the ignore command/clause itself.
I was focused on the literal git diff

We’re currently doing this before the actual git diff check:

if [[ -v INCOMING_HOOK_URL || "$CACHED_COMMIT_REF" = "$COMMIT_REF" ]]; then
    exit 1
fi

This checks if the build was triggered by a build hook or if the build was run after a cleared cache. in both cases it doesn’t skip the build.

hi @VanCoding welcome to our forums!

If you want to build to stop (not proceed) under those conditions you need to do exit 0, not exit 1:

Can you please try switching the logic to see if it behaves as expected?

@gualter I posted this as an answer to the original question. It solves the problem that builds are skipped even when triggered through a build hook or throug the UI. With my solution, they’re not skipped anymore.

@VanCoding

Oh, awesome! Thanks for the clarification and for taking the time to post this for the benefit of others!