Closed Sam-Levene closed 6 years ago
I believe you're confusing operating system environment variables with Newman environment variables. The proxy documentation requires HTTP_PROXY
being set in the operating system environment variables, which can be done as shown below:
set HTTP_PROXY=[YOURPROXY] && newman run C:\Users\sam.levene\projects\Postman_API_Testing\Public_API_Tests.postman_collection.json ```
Sadly, that didn't do it. Same errors as shown above; only this time, I followed your suggestion and typed set HTTP_PROXY=[MYPROXY] && newman run C:\Users\sam.levene\projects\Postman_API_Testing\Public_API_Tests.postman_collection.json
Closing - This works by using a virtual machine to bypass the proxy issues.
HTTP_PROXY='http://login:password@p.kagda.ru:80/' newman run postman_collection.json
works for me so
I need to put two proxies in the newman run CLI. I have a request that needs the proxy and another request that is localhost that doesn't need it. I need the proxy not to apply for the localhost
set HTTP_PROXY=example.com NO_PROXY=localhost && newman run collection.json
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.
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
Trying to use newman to integrate the postman collections in docker command.. Integration is working but when I try to send notification of newman result to slack getting timeout ..This is the comand I have used: "docker run -e http_proxy -e https_proxy --network=host -t postman/newman run newman_sample.json --insecure --color off --disable-unicode --reporters cli,slack --reporter-slack-webhook-url "xxxx". Please help to resolve the 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):