Commit da5124ec authored by FulcrandG's avatar FulcrandG
Browse files

newman

parent 4903d6aa
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -6,13 +6,18 @@ Launch a Postman collection of requests to test your API using [newman](https://

## How to use it

1. Add a Postman collection to your project
1. Add a Postman collection to your project and a globals file to use your variables
2. Add the corresponding URL to your `.gitlab-ci.yml` file (see [Getting
   started](/use-the-hub)). Example:

   ```yaml
   include:
     - remote: 'https://jobs.r2devops.io/newman.yml'

   newman:
      services:
        - name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
          alias: app
   ```
3. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
@@ -31,3 +36,5 @@ Launch a Postman collection of requests to test your API using [newman](https://
| Name | Description | Default |
| ---- | ----------- | ------- |
| `NEWMAN_COLLECTION` <img width=100/> | Name of the Postman collection <img width=175/> | `postman_collection.json` <img width=100/> |
| `NEWMAN_GLOBALS_FILE` | Name of the Postman globals file for [variables](https://learning.postman.com/docs/sending-requests/variables/) | ` ` |
| `NEWMAN_ADDITIONAL_OPTIONS` | Other [options](https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/) you may want to use with Newman | ` ` |
+6 −2
Original line number Diff line number Diff line
@@ -5,12 +5,16 @@ newman:
  image: node:15.4.0
  stage: dynamic_tests
  variables:
    NEWMAN_GLOBALS_FILE: "postman_globals.json"
    NEWMAN_COLLECTION: "postman_collection.json"
    NEWMAN_GLOBALS_FILE: ""
    NEWMAN_ADDITIONAL_OPTIONS: ""
    NEWMAN_JUNIT_REPORT: "newman-report.xml"
  script:
    - npm install -g newman newman-reporter-junitfull
    - newman run ${NEWMAN_COLLECTION} -g ${NEWMAN_GLOBALS_FILE} -r junitfull --reporter-junitfull-export ${NEWMAN_JUNIT_REPORT} -n 2
    - if [[ ! -z ${NEWMAN_GLOBALS_FILE} ]]; then
    -   NEWMAN_ADDITIONAL_OPTIONS+="-g ${NEWMAN_GLOBALS_FILE}"
    - fi
    - newman run ${NEWMAN_COLLECTION} -r junitfull --reporter-junitfull-export ${NEWMAN_JUNIT_REPORT} -n 2 ${NEWMAN_ADDITIONAL_OPTIONS}
  artifacts:
    reports:
      junit: ${NEWMAN_JUNIT_REPORT}