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.

Running Newman behind a proxy with --global-var or set HTTP_PROXY fails

See original GitHub issue

1. Newman Version: 3.8.3 2. OS details (type, version, and architecture): Windows 7 Enterprise 64-bit 3. Are you using Newman as a library, or via the CLI? CLI 3. Did you encounter this recently, or has this bug always been there: Encountered recently 4. Expected behaviour: Expected Newman to work correctly 5. Command / script used to run Newman:

  • newman run C:\Users\sam.levene\projects\Postman_API_Testing\Public_API_Tests.postman_collection.json --global-var "HTTP_PROXY=[MYPROXY]" --global-var "HTTPS_PROXY=[MYPROXY]"

6. Sample collection, and auxilliary files (minus the sensitive details): ? None 7. Screenshots (if applicable): capture4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
gorlovkacommented, May 6, 2020

HTTP_PROXY=‘http://login:password@p.kagda.ru:80/’ newman run postman_collection.json

works for me so

0reactions
Earsilcommented, Nov 7, 2022

I’m having trouble trying to pass proxy settings as environment variables to newman running within a docker container. As documented here, the above mentioned variables are being respected by newman. Within a dockerized setup, I was able to validate that as well when I built my own custom newman image that has the proxy variables set to the desired values. Though, this should obviously not be the way to go (& I do not want to maintain my own custom newman Image).

Could anyone provide a working example of a dockerized newman call (meaning docker run ...), where the HTTP_PROXY, HTTPS_PROXY & NO_PROXY variables with corresponding values are being passed as operation system environment variables (not to be confused with postman/newman env-vars) via -e?

To clarify what I mean, here is a working sample command, where only the postman/newman environment is being passed as a environment variable to the docker container:

docker run --rm -v ~/path/to/my/postman/files:/etc/newman -t postman/newman:alpine run /etc/newman/my_collection.postman_collection.json -e "/etc/newman/my_environment.postman_environment.json" --env-var "myvar1=myvalue1" --env-var "myvar2=myvalue2" --verbose --reporters cli,junit --reporter-junit-export /etc/newman/my-newman-report.xml

What I’m trying to get to work:

docker run --rm -v ~/path/to/my/postman/files:/etc/newman -t postman/newman:alpine run /etc/newman/my_collection.postman_collection.json -e "/etc/newman/my_environment.postman_environment.json" --env-var "myvar1=myvalue1" --env-var "myvar2=myvalue2" -e "HTTP_PROXY=myhttpproxyadress" -e "HTTPS_PROXY=myhttpsproxyadress" -e "NO_PROXY=myexcludedadresses" --verbose --reporters cli,junit --reporter-junit-export /etc/newman/my-newman-report.xml

When running the call above for instance, I get the following error:

error: could not load environment
  ENOENT: no such file or directory, open 'HTTPS_PROXY=http://myproxy:proxyport'

It seems like the only thing that can be passed to the docker container as an environment variable is the postman/newman environment for the collection. When adding any additional environment values, the command seems to break. The example above exists with an error, as it seems like newman is confusing the additional environment variables as potential values for the newman environment.

As a workaround, I’m currently passing an .env file via --env-file flag to the docker run command. Though, this solution would not be sufficient if for instance one would like to pass some kind of sensitive data at runtime to the container.

Move your -e setting just after run, because in your case they are not treated as docker arg, but arg for newman.

docker run --rm --env-var "myvar1=myvalue1" --env-var "myvar2=myvalue2" -e "HTTP_PROXY=myhttpproxyadress" -e "HTTPS_PROXY=myhttpsproxyadress" -e "NO_PROXY=myexcludedadresses" -v ~/path/to/my/postman/files:/etc/newman -t postman/newman:alpine run /etc/newman/my_collection.postman_collection.json -e "/etc/newman/my_environment.postman_environment.json" --verbose --reporters cli,junit --reporter-junit-export /etc/newman/my-newman-report.xml

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running Newman behind a proxy with --global-var or set ...
Running Newman behind a proxy with --global-var or set HTTP_PROXY fails ; 1. Newman Version: 3.8.3 ; 2. OS details (type, version, and ......
Read more >
How to set proxy when we run collection using command line
To test our Api we are setting proxy in our Postman app, but when we run it through command line its failing since...
Read more >
how to specify on newman what port and host to run on
After digging and reading a ton I've figured out the best and simplest way to do so: just setting up the following environment...
Read more >
newman the cli companion for postman - npm
The newman run command allows you to specify a collection to be run. ... Multiple CLI global variables can be added by using...
Read more >
API tests with newman and postman - Rafaela Azevedo
Now on postman, you can create a collection and start to feed with your ... To run your tests from the command line...
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