Webhook icon
Commands icon
Docker icon
Script icon
If icon
SlackIncomingWebhook icon
Fail icon
Log icon

Newman (Postman CLI) Automated API Contract Regression Gate

Execute Postman API test collections with Newman on deployment, parse assertion results, gate downstream promotion, and send test reports to Slack.

Categories
CoreInfrastructure

API integration and contract regression tests are frequently authored by developers and QA engineers in Postman collections. However, integrating these tests into continuous delivery pipelines often introduces hurdles:

  • Raw CLI output logs from CI scripts are cluttered and hard to parse during rapid release rollouts.
  • Lack of automated gating: broken endpoints often go unnoticed until end users report errors in staging or production.
  • Missing multi-stage orchestration: post-deploy smoke tests should automatically notify on-call teams with structured assertion diagnostics rather than generic job failure notifications.

This blueprint bridges Postman and continuous delivery:

  • Triggers on demand via an event-driven Webhook endpoint designed for CI/CD post-deployment steps.
  • Executes the target Postman collection inside an isolated postman/newman:alpine container via Kestra's Docker task runner.
  • Parses Newman's JSON execution report in Python to extract total requests, test assertions, failure causes, and latency averages.
  • Enforces a configurable quality gate: if assertions fail beyond tolerance, it halts pipeline promotion and delivers an actionable failure card to Slack.

How it works

  1. post_deploy_webhook receives incoming release triggers from GitHub Actions, GitLab CI, ArgoCD, or Helm hooks with collection_url and environment_name.
  2. run_newman_tests launches postman/newman:alpine on Docker to execute the collection with --reporters cli,json and generates newman-report.json.
  3. parse_test_results runs a Python script to parse newman-report.json, calculating pass rates, average response latency, and extracting failed test names with error messages.
  4. evaluate_quality_gate (io.kestra.plugin.core.flow.If) branches:
    • If failed assertions exceed max_failed_assertions_allowed: posts an alert card to Slack and halts the execution via Fail.
    • If compliant: logs pass metrics and dispatches a confirmation card.
  5. An errors block catches Docker runner crashes or network timeouts.

What you get

  • Instant Post-Deploy Verification: Automated smoke and regression testing before promoting releases to production.
  • Actionable Slack Diagnostics: Alerts pinpoint the exact failing request, assertion name, and error message.
  • Universal CI/CD Compatibility: Simple webhook trigger seamlessly integrates into any CD pipeline via curl.
  • Zero Credential Exposure: Webhook tokens and Slack URLs are secured using Kestra namespace secrets.

Prerequisites

  • Docker daemon access configured on the Kestra worker.
  • An exported Postman collection JSON file accessible via HTTP/HTTPS (or GitHub raw URL).
  • An incoming Slack webhook URL for notifications.

Secrets

  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL.

Quick start

  1. Configure SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Set collection_url to your Postman collection JSON URL (e.g., hosted on GitHub or an internal asset server).
  3. Call the post_deploy_webhook from your CI/CD pipeline post-deployment:
    curl -X POST "https://kestra.example.com/api/v1/executions/webhook/company.qa/newman-postman-api-regression-gate/run-api-tests" \
      -H "Content-Type: application/json" \
      -d '{
        "collection_url": "https://raw.githubusercontent.com/org/repo/main/tests/api-tests.json",
        "environment_name": "staging"
      }'
    
  4. Review the execution history and Slack channel for the test assertion breakdown.

How to extend

  • Postman Environment Injection: Add an input for Postman environment files (--environment <env.json>) to test across multiple staging endpoints.
  • Multi-Collection Matrix: Wrap run_newman_tests inside an io.kestra.plugin.core.flow.Loop to run multiple microservice test suites in sequence or parallel.
  • Jira Issue Creation: Automatically create bug tickets in Jira for failing assertions.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.