question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add site-specific environment variables in local builds

See original GitHub issue

This issue is part of the bigger issue at #667

Site-specific environment variables (git, build, etc.) are missing in local builds (Netlify CLI and programmatically):

  • BRANCH
  • BUILD_ID
  • CACHED_COMMIT_REF
  • COMMIT_REF
  • CONTEXT
  • DEPLOY_ID
  • DEPLOY_PRIME_URL
  • DEPLOY_URL
  • HEAD
  • NETLIFY_IMAGES_CDN_DOMAIN
  • PULL_REQUEST
  • REPOSITORY_URL
  • REVIEW_ID
  • URL

My first question is whether the list above is correct?

My second question is for @netlify/backend: how to retrieve the information above? I know the getSite API endpoint can be used, but does it include all that information? Can someone pinpoints which property is used for each environment variable? Are some of the environment variables using some conditional logic to find out their value?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidWellscommented, Feb 19, 2020

We don’t need NETLIFY_IMAGES_CDN_DOMAIN

URL is important. ( REPOSITORY_URL too but less so)

CLI should be able to pass in this value

1reaction
kitopcommented, Feb 18, 2020

I believe the backend work on the API token passed to Netlify Build (netlify/bitballoon#4980) should be done first to complete that item @DavidWells @kitop?

Why’s that? Isn’t this for running build in local CLI (ie, user’s machine)? If so, it should have a user token already.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to: Use Environment Variables in a Build - MSBuild
Learn how to access environment variables in MSBuild project files, and use environment variables to set build options without modifying the ...
Read more >
Build environment variables | Netlify Docs
Identify environment variables available in the build environment, set your own environment variables, and use environment variables during builds.
Read more >
Environment Variables: What They Are and How To Use Them
Environment variables add dynamicity to your static code base; you can switch between internal/external resources based on the value of the ...
Read more >
Adding Custom Environment Variables | Create React App
Environment variables are embedded into the build, meaning anyone can view them by inspecting your app's files. The environment variables are ...
Read more >
What Are Environment Variables and How Can I Use Them ...
If you'd ever like to change that variable or add more, you can navigate to the Environment section of the Build & deploy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found