Build step injects env vars only when using same value for all contexts, since today

Hi!

I’m using netlify-cli to build my team’s sites using different env vars on different contexts. This was working just fine until yesterday, both in our CI and locally when doing manual builds.

The only way I could identify this issue was by creating a new site, setting up a brand new vite project and printing to console the available env vars during the build (I set a single env var in the Netlify UI). These are my findings:

  • If I choose “Same value for all deploy contexts”, the cli successfully injects the env var and I see it in the console.
  • If I chosse “Different value for each deploy context”, the cli won’t inject any env variable at all. It doesn’t matter if I specity the context with --context production or --context branch-deploy BUT, for some reason it works with --context dev and the corresponding value is injected.
  • If I keep the “Different value for each deploy context”, and try to do netlify env:list --context production it fetches the right values, same for branch-deploy and dev contexts.

So, again, it seems like since today, something stopped workint when trying to do a build specifying the production or branch-deploy contexts, or when not specifying context.

Any help figuring this out is infinitely appreciated.

Just want to clarify:

If the site has multiple env vars added, only the env variables that have the “Same value for all deploy contexts” are injected. Any variable with “Different value for each deploy context”, is missing in the same call to netlify build. This tells me that the injection is happening, but something is off.

For anyone facing this, my workaround so far is stop relying on env var injection, adding an extra step to download the values to an .env file with netlify env:list --plain --context branch-deploy > .env before the actual build.

Does the API work: Netlify API documentation? CLI uses the API, so if the API works, the CLI should work the same.

Thanks for reaching out @hrishikesh.

Today I downgraded to 17.33.3 and everything works just fine. Went up to 17.33.4 to confirm (latest version as of today), and indeed something went wrong on that last patch.

I’m going to stick with 17.33.3 for now and mark this as solved when I get to confirm the version in which this issue gets fixed.

1 Like