Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.
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.