Skip to content
Latchkey

How to Run Postman Collections With Newman in CI

Newman is Postman's command-line runner, so a collection that passes in the app can run unchanged in CI.

Install newman, then run newman run against your exported collection and environment. Add a JUnit reporter so the job surfaces failed assertions to GitHub.

Steps

  • Export the collection and environment JSON from Postman into the repo.
  • Install Newman with npm install -g newman (or use npx).
  • Run newman run <collection> -e <env> and add -r junit for a report.
  • Upload the JUnit XML so failures show in the run summary.

Workflow

.github/workflows/ci.yml
jobs:
  api-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
      - run: npm install -g newman
      - run: >-
          newman run collections/api.postman_collection.json
          -e collections/ci.postman_environment.json
          -r cli,junit --reporter-junit-export results/newman.xml
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: newman-report
          path: results/newman.xml

Gotchas

  • Newman exits non-zero on any failed assertion, which correctly fails the job.
  • Override collection variables at run time with --env-var name=value instead of baking secrets into the export.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →