Dumping Environment Variables for a Netlify Site locally

22 Views Asked by At

So we have some Netlify sites, we are not using Netlify to build the site locally but I would like to debug various issues on sites locally, so that involves taking the proper environment variables for the site and dumping them into an env.local file and building.

We have used Netlify cli to create a .Netlify folder in the site code, and inside that is a state.json - If I add a siteId property to this JSON

{
siteId: "id for netlify site"
}

and then run the following netlify cli command

netlify env:list --plain true > env.local

we get all the environment variables and dump them into the env.local, however we have a lot of different sites and more coming. Editing this siteId property by hand is problematic. I could use another tool to change it before running my command to dump variables but that isn't necessarily the most scalable either - my preferred solution would be if I could do something like

netlify --useSiteID new id 

or if I could have multiple site ids in the state.json and specify via command line which one I wanted to use.

0

There are 0 best solutions below