newman run: Execute Postman Collections in CI
newman run collection.json executes every request and test in a Postman collection and exits non-zero if any test fails.
Newman is Postman's command-line runner. It takes a collection you exported (or a URL), runs the requests and their test scripts in order, and reports pass/fail with a CI-friendly exit code.
What it does
newman run executes a Postman collection: it sends each request, runs the associated test scripts, and aggregates the results. -e supplies an environment file of variables, -d a data file for iterations, and -r selects reporters (cli, json, junit). A failed test or request assertion makes the process exit non-zero.
Common usage
newman run collection.json
newman run collection.json -e staging.postman_environment.json
newman run collection.json -r cli,junit --reporter-junit-export report.xml
# fail fast and bound each request
newman run collection.json --bail --timeout-request 5000Options
| Flag | What it does |
|---|---|
| <collection> | Postman collection file or URL to run |
| -e <env> | Environment file of variables |
| -d <data> | Data file to iterate the run over |
| -r <reporters> | Reporters: cli, json, junit |
| --bail | Stop on the first failure |
| --timeout-request <ms> | Per-request timeout |
In CI
Export a JUnit report with -r junit --reporter-junit-export report.xml so your CI provider shows per-request results. Newman exits non-zero on any failed assertion, so it gates the step without extra scripting. Use --bail to stop at the first failure when you want a fast signal.
Common errors in CI
A failing test prints AssertionError with the expected versus actual value under the request in the CLI report, and the run exits 1. ECONNREFUSED under a request means the target service is not up. unable to read data from file "collection.json" means a wrong path. ReferenceError in the summary means a test script referenced an undefined variable, often a missing environment file passed with -e.