Allow (process) env vars to be used as Environment Variables
See original GitHub issueSimilar to #647 but instead of passing variables as command line switches, allow process.env
vars to be used as (Postman) Environment Variables where none already exists. In other words a Postman Environment Variable (api_url
) would have precedence over process.env.API_URL
.
This is desirable because there are some environment specific settings (passwords) that I don’t want to store in the .postman_environment.json
file (which is checked in to source control). Yes, I can rewrite my .postman_environment.json
file before I call newman run
but using process.env
would be more convenient.
Any other suggestions welcome 😃
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:19 (9 by maintainers)
Top Results From Across the Web
Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >Setting Environment Variables for Node to retrieve
You can set the environment variable through process global variable as follows: process.env['NODE_ENV'] = 'production';.
Read more >Node Environment Variables: Process env Node
Node environment variables are strategies to define and consume environment-specific configurations and process env node. Learn how.
Read more >Using Environment Variables in Node.js for App Configuration ...
Set the NODE_ENV environment variable to "development" , enabling debug mode in your development environment; Provide environment-specific ...
Read more >How to use environment variables in Node.js | by Ali Kamalizade
Let's take a look how you can use custom environment variables in Node. I can recommend the dotenv module which makes it easy...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As discussed earlier, automatic insertion brings with it security concerns. You’d have to use the
--global-var
option as demonstrated above. The former section in my previous comment was just a working sample.I understand the concern for users who may inadvertently allow the exfiltration of sensitive environment variables by malicious collections. However, there is another security concern to consider here, too.
On many UNIX-family operating systems, the full command line (including arguments) for each process is visible to all. This means that if I want to pass an API token to a collection and use
newman run collection.json --global-var token=$token
, the value of$token
(expanded by the shell) will be visible to all users on the host wherenewman
is running. This is not ideal, especially on shared hosts like build servers.I like @gaieges’s suggestion of filtering by a
NEWMAN_
prefix.Alternatively, a list of specific variable names to import could be provided as a command line argument. For example:
With considerations like the above, shell environment variables could actually be more secure than command line arguments.