Can't change Base URL at build time using CLI

Currently trying to set an env:set variable as per the docs on a script before I deploy via the CLI.

I need to do this to dynamically change a variable depending on the current branch that I am pushing code to and the command looks like this:

./node_modules/.bin/netlify env:set AUTH0_BASE_URL "$base_url" --context branch:"$branch_name" --filter platform

But I get this error when running on CircleCI:

 Error: To specify a context or scope, please run netlify open:admin to open the Netlify UI and opt in to the new environment variables experience from Site settings

The code is structured on a monorepo, have tried running the command both at root and at project level but the errors are the same.

When running the script locally I can create the environment variable correctly and see it displayed in the Netlify UI.

Other commands work fine and have no issue linking to the project correctly such as:

./node_modules/.bin/netlify deploy --build --dir=apps/<<parameters.target>>/.next --site <<parameters.site_id>> --auth $NETLIFY_API_TOKEN --filter <<parameters.target>> --alias $ALIAS

May I add, this seems like a very longwinded way to change environment variables at build time as this could be very easily done through scripts to create an .env file or even append to the netlify.toml file but Netlify does not support reading from .env and the environment variables set on netlify.toml are not exposed to functions.

Without a site name, there’s not a lot we can check here.

You can write environment variables to your .env file and bundle them with Functions: How to Include Files in Netlify Serverless Functions. Once that’s done, it’s up to your framework (or yourself if you’re writing the Function manually) to read that file when serving the site.