$npx -y skills add LambdaTest/agent-skills --skill newman-cicd-helperGenerate ready-to-use CI/CD pipeline configurations that install and run Newman for automated API testing. Use this skill whenever the user wants to run Newman in a CI pipeline, integrate Postman collections into automated builds, set up API tests in GitHub Actions, GitLab CI, Je
| 1 | # Newman CI/CD Integration Generator |
| 2 | |
| 3 | Generate complete, copy-paste-ready CI/CD pipeline configs that install Newman and run Postman collections as part of automated builds. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## What to Collect From the User |
| 8 | |
| 9 | Before generating a config, determine: |
| 10 | 1. **CI platform** — GitHub Actions, GitLab CI, Jenkins, Azure DevOps, CircleCI, Bitbucket? |
| 11 | 2. **Collection source** — local file in repo, or Postman API URL? |
| 12 | 3. **Environment** — local env file in repo, or env vars injected by CI secrets? |
| 13 | 4. **Reporters needed** — JUnit XML (for CI test results panel), HTML report, or both? |
| 14 | 5. **Node.js version** preference (default: 18) |
| 15 | 6. **Trigger** — on every push, pull request, schedule, or after deploy? |
| 16 | 7. **Fail build on test failure?** — almost always yes; confirm |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Platform Templates |
| 21 | |
| 22 | ### GitHub Actions |
| 23 | |
| 24 | ```yaml |
| 25 | name: API Tests |
| 26 | |
| 27 | on: |
| 28 | push: |
| 29 | branches: [main, develop] |
| 30 | pull_request: |
| 31 | |
| 32 | jobs: |
| 33 | api-tests: |
| 34 | runs-on: ubuntu-latest |
| 35 | |
| 36 | steps: |
| 37 | - name: Checkout repository |
| 38 | uses: actions/checkout@v4 |
| 39 | |
| 40 | - name: Set up Node.js |
| 41 | uses: actions/setup-node@v4 |
| 42 | with: |
| 43 | node-version: '18' |
| 44 | |
| 45 | - name: Install Newman |
| 46 | run: | |
| 47 | npm install -g newman |
| 48 | npm install -g newman-reporter-htmlextra |
| 49 | |
| 50 | - name: Run API tests |
| 51 | run: | |
| 52 | newman run ./collections/my-api.json \ |
| 53 | -e ./environments/staging.json \ |
| 54 | -r cli,junit,htmlextra \ |
| 55 | --reporter-junit-export ./results/junit.xml \ |
| 56 | --reporter-htmlextra-export ./results/report.html \ |
| 57 | --reporter-htmlextra-title "API Test Results" |
| 58 | env: |
| 59 | BASE_URL: ${{ secrets.BASE_URL }} |
| 60 | API_KEY: ${{ secrets.API_KEY }} |
| 61 | |
| 62 | - name: Publish test results |
| 63 | uses: dorny/test-reporter@v1 |
| 64 | if: always() |
| 65 | with: |
| 66 | name: Newman API Tests |
| 67 | path: results/junit.xml |
| 68 | reporter: java-junit |
| 69 | |
| 70 | - name: Upload HTML report |
| 71 | uses: actions/upload-artifact@v4 |
| 72 | if: always() |
| 73 | with: |
| 74 | name: api-test-report |
| 75 | path: results/report.html |
| 76 | ``` |
| 77 | |
| 78 | --- |
| 79 | |
| 80 | ### GitLab CI |
| 81 | |
| 82 | ```yaml |
| 83 | stages: |
| 84 | - test |
| 85 | |
| 86 | api-tests: |
| 87 | stage: test |
| 88 | image: node:18-alpine |
| 89 | before_script: |
| 90 | - npm install -g newman newman-reporter-htmlextra |
| 91 | script: |
| 92 | - | |
| 93 | newman run ./collections/my-api.json \ |
| 94 | -e ./environments/staging.json \ |
| 95 | --env-var "BASE_URL=$BASE_URL" \ |
| 96 | --env-var "API_KEY=$API_KEY" \ |
| 97 | -r cli,junit,htmlextra \ |
| 98 | --reporter-junit-export results/junit.xml \ |
| 99 | --reporter-htmlextra-export results/report.html |
| 100 | artifacts: |
| 101 | when: always |
| 102 | reports: |
| 103 | junit: results/junit.xml |
| 104 | paths: |
| 105 | - results/report.html |
| 106 | expire_in: 7 days |
| 107 | variables: |
| 108 | BASE_URL: $BASE_URL # Set in GitLab CI/CD > Variables |
| 109 | API_KEY: $API_KEY |
| 110 | ``` |
| 111 | |
| 112 | --- |
| 113 | |
| 114 | ### Jenkins (Declarative Pipeline) |
| 115 | |
| 116 | ```groovy |
| 117 | pipeline { |
| 118 | agent any |
| 119 | |
| 120 | tools { |
| 121 | nodejs 'NodeJS-18' // Configure in Global Tool Configuration |
| 122 | } |
| 123 | |
| 124 | stages { |
| 125 | stage('Install Newman') { |
| 126 | steps { |
| 127 | sh 'npm install -g newman newman-reporter-htmlextra' |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | stage('Run API Tests') { |
| 132 | steps { |
| 133 | sh ''' |
| 134 | newman run ./collections/my-api.json \ |
| 135 | -e ./environments/staging.json \ |
| 136 | -r cli,junit,htmlextra \ |
| 137 | --reporter-junit-export results/junit.xml \ |
| 138 | --reporter-htmlextra-export results/report.html \ |
| 139 | --reporter-htmlextra-title "API Tests - ${BUILD_NUMBER}" |
| 140 | ''' |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | post { |
| 146 | always { |
| 147 | junit 'results/junit.xml' |
| 148 | publishHTML([ |
| 149 | allowMissing: false, |
| 150 | alwaysLinkToLastBuild: true, |
| 151 | keepAll: true, |
| 152 | reportDir: 'results', |
| 153 | reportFiles: 'report.html', |
| 154 | reportName: 'Newman API Test Report' |
| 155 | ]) |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | ``` |
| 160 | |
| 161 | --- |
| 162 | |
| 163 | ### Azure DevOps |
| 164 | |
| 165 | ```yaml |
| 166 | trigger: |
| 167 | branches: |
| 168 | include: |
| 169 | - main |
| 170 | |
| 171 | pool: |
| 172 | vmImage: 'ubuntu-latest' |
| 173 | |
| 174 | steps: |
| 175 | - task: NodeTool@0 |
| 176 | inputs: |
| 177 | versionSpec: '18.x' |
| 178 | displayName: 'Set up Node.js' |
| 179 | |
| 180 | - scri |