</>

Technology

Postman

Difficulty

Advanced

Interview Question

What is Newman and how do you use it for Postman CI/CD?

Answer

What is Newman?

Newman is the command-line collection runner for Postman. It allows you to run Postman collections directly from the terminal, making it perfect for CI/CD integration.

Installation

Bash
npm install -g newman

# With HTML reporter
npm install -g newman-reporter-html

Basic Usage

Bash
# Run a collection
newman run MyCollection.json

# Run with environment
newman run MyCollection.json -e staging-environment.json

# Run with data file
newman run MyCollection.json -d testdata.csv

# Run with HTML report
newman run MyCollection.json --reporters html --reporter-html-export results/report.html

# Run with JUnit XML (for CI systems)
newman run MyCollection.json --reporters junit --reporter-junit-export results/junit.xml

Exporting from Postman

  1. Open your Collection
  2. Click ...Export
  3. Choose Collection v2.1
  4. Save the JSON file
  5. Run with Newman

CI/CD Integration Examples

GitHub Actions

YAML
- name: Run API Tests
  run: |
    npm install -g newman newman-reporter-html
    newman run collection.json -e production.json --reporters cli,html \
      --reporter-html-export report.html

Jenkins

Bash
newman run ${WORKSPACE}/collection.json \
  -e ${WORKSPACE}/env.json \
  --reporters junit \
  --reporter-junit-export ${WORKSPACE}/results/newman-report.xml

Newman Options

FlagDescription
-e, --environmentEnvironment file
-d, --iteration-dataData file (CSV/JSON)
-n, --iteration-countNumber of iterations
--delay-requestDelay between requests (ms)
--timeout-requestRequest timeout (ms)
--reportersOutput reporters (cli, html, junit)
--bailStop on first test failure

Advantages of Newman

  • No Postman UI needed — headless execution
  • Integrate with any CI/CD tool (Jenkins, GitHub Actions, GitLab CI, Azure DevOps)
  • Generate test reports automatically
  • Run collections programmatically in Node.js

Follow AutomateQA

Related Topics