Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)48k · #5477

postman-newman-automation

Skill này làm gì

Công cụ này tạo lệnh và script để chạy kiểm thử API tự động. Nó giúp thực thi các collection kiểm thử Postman trong môi trường phát triển hoặc trong hệ thống CI/CD (tích hợp và triển khai liên tục) như Jenkins.

Khi nào nên dùng

  • ✓Khi bạn cần chạy kiểm thử API Postman ngoài giao diện đồ họa.
  • ✓Khi tự động hóa việc thực thi kiểm thử API trong quy trình CI/CD.
  • ✓Khi tạo báo cáo kiểm thử API ở các định dạng như HTML hoặc XML.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/postman-newman-automation/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/postman-newman-automation/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tạo lệnh để chạy collection “api_tests.json” với môi trường “prod.json”, tạo báo cáo HTML tên “report.html” và dừng lại nếu có bài kiểm thử thất bại.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ dùng Newman, một chương trình dòng lệnh dành cho Postman. Nó xây dựng các lệnh cần thiết, bao gồm tùy chọn để chỉ định tệp collection, môi trường và loại báo cáo.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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') {

…
Câu hỏi thường gặp

Newman là gì?

Newman là phiên bản dòng lệnh của Postman, cho phép bạn chạy kiểm thử API trực tiếp từ terminal mà không cần mở giao diện Postman.

“Collections” và “environments” trong Postman là gì?

Collections nhóm các yêu cầu API và bài kiểm thử của bạn. Environments lưu các biến (như URL hoặc token) thay đổi tùy theo nơi bạn kiểm thử (phát triển, production, v.v.).

CI/CD là gì?

CI/CD (Continuous Integration/Continuous Deployment, tích hợp và triển khai liên tục) là thực hành phát triển phần mềm trong đó việc kiểm thử và triển khai được tự động hóa. Các công cụ như Jenkins được dùng cho việc này.

Chi tiết

Mô tả gốc của tác giả

Generate Newman CLI commands, configuration files, Jenkins pipeline scripts, and shell automation for running Postman collections in CI/CD or local environments.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5477
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự