My question:
How to access environment variable passed from command line in pre-request script?
command I am using:
newman run ‘collection.json’ --env-var “Key=Value”
In pre-request script:
pm.environment.get(“Key”)
Value for above expression is undefined
.
Details :
I wanted to pass secrets from pipeline rather than hardcoding in the newman script. Its best practise to keep secrets out of code repository. So I am using environment variable.
Postman version to create collection: v10.8.0
newman npm version: 5.3.2
How I found the problem:
When specified env var in command line and tried to extract it in pre-request script.
I’ve already tried:
I have tried global variables in command line as well, not working it either.
Any help much appreciated.