Support Forums

Git environment variables showing as undefined

Hi everyone - I’m trying to access the REPOSITORY_URL environment variable. It’s working just fine on my local machine with netlify dev but when I deploy, it’s giving an undefined. I logged the entire process.env and see no Git metadata variables. Any ideas?

Hi, @rockorager. Where did you log process.env? Is this being logged by the build command that builds your site? If so, would you please send us a link to that deploy (or tell us the deploy id)?

Hey Luke -

I logged it just using console.log(process.env). It doesn’t look like I said it in the original post, but I am doing all of this within Netlify Functions (same with that console.log)

Not all environment variables from the build environment are passed to the function environment. The typical solution for this is to embedded the environment variable as a literal string in the function source code during the site build and deploy process.

There is a third-party build plugin which has been created to automated that process here:

If there are other questions, please reply anytime.