newman run: Usage, Options & Common CI Errors
newman runs a Postman collection from the command line and gates CI on it.
newman is the CLI runner for Postman collections, the standard way to run API test suites in CI. When any request or test assertion fails, newman exits 1 and fails the job.
What it does
newman run executes a Postman collection (.json or a Postman URL), running each request and its pm.test assertions, applying an environment and global variables. It produces CLI, JUnit, or HTML reports and a non-zero exit on any failure.
Common usage
newman run collection.json
newman run collection.json -e env.json -g globals.json
newman run collection.json --reporters cli,junit --reporter-junit-export results.xml
newman run collection.json --bail # stop at first failure
newman run collection.json --env-var "token=${TOKEN}"Options
| Flag | What it does |
|---|---|
| -e <file> | Postman environment file |
| -g <file> | Postman globals file |
| --reporters <list> | cli, json, junit, html, … |
| --bail | Abort the run on the first failure |
| --env-var "k=v" | Override/inject an environment variable |
| -n / --iteration-count <N> | Run the collection N times |
Common errors in CI
newman exits 1 when any request errors or any pm.test assertion fails - that is the CI gate. The summary table shows "assertions ... failed" with the count; inspect it to find the failing test. "Error: ENOENT: no such file ... collection.json" means a wrong path or the collection was not checked out. "unable to load environment" → bad -e path. "getaddrinfo ENOTFOUND" is DNS - the base URL host is wrong or the service is unreachable. Use --bail to fail fast and --reporter-junit-export for CI test reports.