-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have netlify build
use .env
files like netlify dev
to override local ENV variables
#1514
Comments
Hi @moop-moop, very interesting - thank you for opening the issue. If not, can you describe the use case? |
Yes, for some cases.
Really, it's pretty much the same reasons as when developers are using them for Possible real world example with Contentful: We might need to create a Contentful environment branch to test a big content model change. The Contentful environment branch could have a different API key while testing/developing. |
Instead of
You can do this in [build.environment]
EXAMPLE_ONE = "one"
EXAMPLE_TWO = "two" Would this solve your problem? I.e. using environment variables while testing/debugging a Build plugin. |
@ehmicky good suggestion! I have Am I missing a critical step? Thanks! |
The one used by Those should be available in your build command and plugins. Is there a repository I could check to reproduce? |
Ah yes, I'm trying to use both, but neither section is picked up when I try to access |
Just to be sure: by "function", do you mean a function inside a Build plugin, a function inside a build command, or a Netlify Function (function-as-a-service)? |
Not exactly. My goal would be to have environment variables that are not committed to a repo. Local only, in-other-words. Another option is to use the Contextual ENV Netlify Build Plugin, but that then requires "local" ENV variables to be stored in Netlify. |
Yes, you're right, if the environment variables are secret, those should not be committed to However, since those environment variables would be only temporary for debugging/testing in your case, wouldn't it work to modify the Note: If the build is tested in production (instead of locally), setting environment variables in the Netlify app would need to be used instead. Another note: |
The following plugin was proposed to add |
This issue has been automatically marked as stale because it has not had activity in 1 year. It will be closed in 14 days if no further activity occurs. Thanks! |
This issue was closed because it had no activity for over 1 year. |
- Do you want to request a feature or report a bug?
feature
- What is the current behavior?
netlify build
only honors ENV variables in the Netlify linked site,netlify.toml
file as far as project level based environment variables.netlify dev
can use a.env
file to override the linked Netlify site environment variables.- If the current behavior is a bug, please provide the steps to reproduce.
N/A
- What is the expected behavior?
The feature request is that
netlify build
behave in the same way asnetlify dev
where a.env
file can be used to override ENV variables.- Reason
Consistency with
netlify dev
, and convenience for working with Netlify Plugin development and Netlify builds (like performance tuning and errors).Working more on the DevOps side, rather that actual site programming/development.
I use
netlify build
almost daily.The text was updated successfully, but these errors were encountered: