Skill

Automate API Tests with Postman Newman on Cloud

Generates Newman CLI commands, a reusable shell script, and Jenkins pipeline configs for running Postman collections, with reporter and flag references.

Works with postmannewmangithubseleniumplaywright

35
Spark score
out of 100
Updated last month
Version 1.0.0

Add to Favorites

Why it matters

Enable AI coding assistants to generate production-grade test automation code across 15+ languages and frameworks, then execute those tests on a cloud platform with 10K+ real devices and 3,000+ browsers for comprehensive quality assurance.

Outcomes

What it gets done

01

Generate expert-level test automation code for Selenium, Playwright, Cypress, Appium, and other frameworks through natural language prompts

02

Execute automated tests on TestMu AI cloud infrastructure across multiple browsers and devices simultaneously

03

Integrate test automation skills into AI assistants like Claude Code, Copilot, Cursor, and Gemini CLI

04

Set up local testing tunnels to test locally hosted applications with cloud-based test execution

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-postman-newman-automation | bash

Overview

Postman Newman Automation

This skill generates Newman CLI commands, a reusable shell script, and Jenkins pipeline configs (declarative or scripted) for running Postman collections, with a full reporter and CLI-flag reference. Use it for running Postman collections via the Newman CLI locally or in Jenkins specifically. For other CI platforms, use the companion CI/CD integration skill instead.

What it does

Generates Newman CLI commands, shell scripts, and Jenkins pipeline configurations for running Postman collections in automated or local environments - distinct from generating configs for other CI platforms, which is a companion skill. It first gathers six parameters: collection source (file path, URL, or Postman API UID), environment (file or inline variables), which reporters are needed, fail behavior (--bail versus running all tests), whether the run is a single pass or data-driven with iteration data, and the target (local shell, Jenkins, or both). It then generates Newman commands for four scenarios: a basic local run with HTML reporting, a run pulled directly from the Postman API by collection UID with an API key, a data-driven run against a CSV with a set iteration count, and a run using inline --env-var overrides instead of an environment file. A reusable shell script wraps the command with set -e, a timestamped report directory, and explicit exit-code handling that echoes pass/fail and points to the report file. For Jenkins it generates either a declarative Jenkinsfile (install stage, test stage, and a post block that publishes the HTML report via publishHTML and JUnit results via junit, always-run regardless of pass/fail) or a scripted Jenkinsfile with try/catch/finally around the Newman invocation, plus a variant showing environment-variable and Jenkins-credential injection instead of a checked-in environment file. A reporter reference covers all four Newman reporters - cli (built-in terminal output), junit (built-in, XML for CI test panels), htmlextra (installed separately via newman-reporter-htmlextra, rich HTML report), and json (built-in, raw results) - combinable as --reporters cli,htmlextra,junit. A quick-reference table covers the common flags: --bail to stop on first failure, --timeout-request/--delay-request for timing control, --iteration-count for repeated runs, --folder to scope to one folder, --env-var for inline variables, --suppress-exit-code to always exit 0, --verbose for full request/response detail, and --color off for clean log output. Output is tailored to what's needed: the ready-to-paste command, the shell script, the Jenkinsfile, setup notes (Node.js 14+ required, install commands), and where report files land. After delivering, it offers to hand off to a companion API Documentation skill using the generated output as input.

newman run collection.json \
  --environment environment.json \
  --reporters cli,htmlextra \
  --reporter-htmlextra-export reports/report.html \
  --bail

When to use - and when NOT to

Use it whenever a user wants to run Postman collections from the command line, generate a Newman CLI invocation, build a reusable shell script around Newman, or set up a Jenkins pipeline specifically for API tests. For other CI platforms (GitHub Actions, GitLab CI, Azure DevOps, CircleCI), a companion CI/CD integration skill covers those directly instead of hand-adapting a Jenkins config.

Inputs and outputs

Input is a collection source, environment, reporter needs, fail behavior, iteration/data-driven requirements, and target environment (shell, Jenkins, or both). Output is a ready Newman CLI command, an executable shell script with exit-code handling, and/or a declarative or scripted Jenkinsfile with report publishing.

Integrations

Generates configs around the Newman CLI (npm install -g newman, optionally newman-reporter-htmlextra) for local shell and Jenkins environments, and hands off to a companion API Documentation skill on request.

Who it's for

API teams who already have a Newman-runnable Postman collection and want a correct CLI command, a reusable shell script, or a Jenkins pipeline with proper reporting and exit-code handling, without hand-assembling the flags and pipeline boilerplate themselves.

Source README

Postman Newman Automation

When to Use

Use this skill when you need generate Newman CLI commands, configuration files, Jenkins pipeline scripts, and shell automation for running Postman collections in CI/CD or local environments. Use this skill whenever the user wants to run Postman collections from the command line, automate API tests, integrate...

Generates Newman CLI commands, shell scripts, and Jenkins pipeline configs
for running Postman collections in automated environments.


Newman Basics

Newman is Postman's CLI runner. Install with:

npm install -g newman
### Optional HTML reporter:
npm install -g newman-reporter-htmlextra

Core Command Structure

newman run <collection> \
  --environment <env-file> \
  --globals <globals-file> \
  --iteration-count <n> \
  --iteration-data <csv-or-json> \
  --reporters <reporter-list> \
  --reporter-htmlextra-export <output.html> \
  --reporter-junit-export <results.xml> \
  --timeout-request <ms> \
  --delay-request <ms> \
  --bail \
  --color on

Step 1 - Gather Requirements

Ask or infer from context:

Parameter Question
Collection source File path, URL, or Postman API UID?
Environment File path or inline variables?
Reporter(s) CLI only, HTML report, JUnit XML?
Fail behavior Stop on first failure (--bail) or run all?
Iterations Single run or data-driven (CSV/JSON)?
Target Local shell, Jenkins, or both?

Step 2 - Generate Newman Command

Basic run (local)

newman run collection.json \
  --environment environment.json \
  --reporters cli,htmlextra \
  --reporter-htmlextra-export reports/report.html \
  --bail

Run from Postman API (by UID)

newman run "https://api.getpostman.com/collections/<UID>?apikey={{POSTMAN_API_KEY}}" \
  --environment environment.json \
  --reporters cli,junit \
  --reporter-junit-export results/junit.xml

Data-driven run (CSV)

newman run collection.json \
  --iteration-data test-data.csv \
  --iteration-count 5 \
  --reporters cli,htmlextra \
  --reporter-htmlextra-export reports/data-driven-report.html

With environment variable overrides (no file needed)

newman run collection.json \
  --env-var "base_url=https://staging.api.example.com" \
  --env-var "token=abc123" \
  --reporters cli

Step 3 - Shell Script

Generate a reusable shell script:

#!/bin/bash
set -e

### Configuration
COLLECTION="./collection.json"
ENVIRONMENT="./environment.json"
REPORT_DIR="./reports"
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")

### Ensure report directory exists
mkdir -p "$REPORT_DIR"

echo "Running Newman collection: $COLLECTION"

newman run "$COLLECTION" \
  --environment "$ENVIRONMENT" \
  --reporters cli,htmlextra,junit \
  --reporter-htmlextra-export "$REPORT_DIR/report_$TIMESTAMP.html" \
  --reporter-junit-export "$REPORT_DIR/junit_$TIMESTAMP.xml" \
  --timeout-request 10000 \
  --bail

EXIT_CODE=$?

if [ $EXIT_CODE -eq 0 ]; then
  echo "✅ All tests passed."
else
  echo "❌ Tests failed. Check report: $REPORT_DIR/report_$TIMESTAMP.html"
  exit $EXIT_CODE
fi

Step 4 - Jenkins Pipeline

Declarative Jenkinsfile (preferred)

pipeline {
  agent any

  environment {
    POSTMAN_ENV = credentials('postman-environment-file') // Jenkins credential ID
  }

  stages {
    stage('Install Newman') {
      steps {
        sh 'npm install -g newman newman-reporter-htmlextra'
      }
    }

    stage('Run API Tests') {
      steps {
        sh """
          newman run collection.json \\
            --environment ${POSTMAN_ENV} \\
            --reporters cli,htmlextra,junit \\
            --reporter-htmlextra-export reports/report.html \\
            --reporter-junit-export reports/junit.xml \\
            --timeout-request 10000 \\
            --bail
        """
      }
    }
  }

  post {
    always {
      // Archive HTML report
      publishHTML(target: [
        allowMissing: false,
        alwaysLinkToLastBuild: true,
        keepAll: true,
        reportDir: 'reports',
        reportFiles: 'report.html',
        reportName: 'Newman API Test Report'
      ])
      // Archive JUnit results
      junit 'reports/junit.xml'
    }
    failure {
      echo 'API tests failed! Check the Newman report.'
    }
  }
}

Scripted Jenkinsfile (if declarative not available)

node {
  stage('Install Newman') {
    sh 'npm install -g newman newman-reporter-htmlextra'
  }

  stage('Run API Tests') {
    try {
      sh """
        newman run collection.json \\
          --environment environment.json \\
          --reporters cli,junit \\
          --reporter-junit-export reports/junit.xml \\
          --bail
      """
    } catch (err) {
      currentBuild.result = 'FAILURE'
      throw err
    } finally {
      junit 'reports/junit.xml'
    }
  }
}

Jenkins with environment variables (no credentials file)

environment {
  BASE_URL = 'https://api.example.com'
  API_TOKEN = credentials('api-token-secret')
}

steps {
  sh """
    newman run collection.json \\
      --env-var "base_url=${BASE_URL}" \\
      --env-var "token=${API_TOKEN}" \\
      --reporters cli,junit \\
      --reporter-junit-export results/junit.xml
  """
}

Step 5 - Reporter Reference

Reporter Install Flag Output
cli built-in --reporters cli Terminal output
junit built-in --reporters junit JUnit XML (for Jenkins)
htmlextra npm i -g newman-reporter-htmlextra --reporters htmlextra Rich HTML report
json built-in --reporters json Raw JSON results

Multiple reporters: --reporters cli,htmlextra,junit


Step 6 - Output

Provide based on what the user needs:

  1. Newman command - ready to paste in terminal
  2. Shell script (run-tests.sh) - with exit code handling
  3. Jenkinsfile - declarative or scripted based on context
  4. Setup notes - Node.js version requirement (≥14), npm install commands
  5. Report locations - where output files will be written

Common Flags Quick Reference

Flag Purpose
--bail Stop run on first test failure
--timeout-request 5000 Per-request timeout in ms
--delay-request 200 Delay between requests in ms
--iteration-count 3 Run collection N times
--folder "Folder Name" Run only a specific folder
--env-var "k=v" Inline environment variable
--suppress-exit-code Always exit 0 (don't fail CI)
--verbose Show full request/response details
--color off Disable color (useful for logs)

After Completing the Newman Commands

Once the CLI command output is delivered, ask the user:

"Would you like me to generate API documentation for this design? (yes/no)"

If the user says yes:

  • Check if the API Documentation skill is available in the installed skills list
  • If the skill is available:
    • Read and follow the instructions in the API Documentation skill
    • Use the API design output above as the input
    • Deliver the documentation as plain text output
  • If the skill is NOT available:
    • Inform the user: "It looks like the API Documentation skill isn't installed.
      You can install it and re-run.

If the user says no:

  • End the task here

Limitations

  • Use this skill only when the task clearly matches its upstream source and local project context.
  • Verify commands, generated code, dependencies, credentials, and external service behavior before applying changes.
  • Do not treat examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.