Home
Support Forums

Ignoring deployment preview builds for specific users

Hi,

My website uses the renovate github bot to bump dependencies, and as such it creates a lot of PRs on the repo. In an effort to save build minutes, I’d like to skip building + creating deployment previews for these PRs, opting to rely on my other github checks and only deploy when merged to master.

To achieve this, I’m trying to use the ignore option described here: How to Ignore Builds - Optimize your Netlify Build Times and here: File-based configuration | Netlify Docs. My netlify.toml config in its entirety looks like this:

[context.deploy-preview]
  ignore = "git log -1 --format='%aN' | grep -i renovate"

Note that I don’t want to set ignore globally for [build], hence the [context.deploy-preview], since my understanding is that it’d then ignore builds from Renovate even on master, which I don’t want (since I still want my website to deploy for real if any commit is merged to master, including Renovate’s).

I verified that locally running git log -1 --format='%aN' | grep -i renovate when the last commit was from Renovate returns 0, which in my understanding would no-op the build (ignoring it). However, if I look at a recent deploy preview such as this one: Netlify App, I can see the line Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'git log -1 --format='%aN' | grep -i renovate', but the build continues on.

This makes me think that the toml file is correct and recognised, but that something’s wrong with my ignore command. Based on the blogpost and docs I had assumed it would be run on the branch making the change, so git log -1 (as used in the blog post for a similar usecase - dependabot) would return the most recent PR’s Renovate commit, and grepping case-insenstively against the commit’s author would return 0. But I assume I’ve made some kind of mistake here so any pointers would be much appreciated.

I should also mention that I tried searching the forum before writing this and found some similar posts, but those seemed from 2020 and were related to not being on the Xenial build image, which I appear to be.

Thanks in advance!

Hiya @jdb8 and very sorry to be so slow to get back to you!

That seems like it should work to me, too!

Could I ask you to try something? Could you create and run as a one-time experiment, a build with the following build command, and try to trigger it in a way (maybe with commit message?) that should “activate” that ignore command. This way we’ll see what is actually coming from that command to confirm that it should work as we expect. Since your usual build command seems to be yarn build, let’s try changing it to:

git log -1 --format='%aN' | grep -i renovate ; echo $? ; yarn build

That should output both what the command returns, and what the “grep” returns as far as exit code, so we can be sure they are what you and I both expect.

Thanks in advance for your help in troubleshooting!

Hey, thanks for the reply!

I just tried your suggestion, and here’s the output from my build log:

6:53:33 PM: $ git log -1 --format='%aN' | grep -i renovate ; echo $? ; yarn build
6:53:33 PM: Renovate Bot
6:53:33 PM: 0

So it seems that the command is returning 0, which would imply that it should skip? I again see this at the beginning of the build log:

6:52:52 PM: Detected ignore command in Netlify configuration file. Proceeding with the specified command: 'git log -1 --format='%aN' | grep -i renovate'

Wondering what could be going on here… my only thought is that in the docs it mentions:

If you would like to use this feature for a site that was created before October 3rd, 2019, you’ll need to re-link your repository to make this feature available for your site.

I do think my site was set up prior to 2019, probably, but I assumed this wasn’t relevant since it seemed to be picking up the ignore command - it just wasn’t working. But other than that I can’t think of why this might not be working.