Commit ef217a77 authored by Protocole's avatar Protocole Committed by Thomas Boni
Browse files

Resolve "[job][newman] Add option to include environment file"

parent 1bc7cea2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ Launch a Postman collection of requests to test your API using [newman](https://
| ---- | ----------- | ------- |
| `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_ENVIRONMENT_FILE` | Name of the Postman environment file for 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 | ` ` |
| `NEWMAN_FAIL_ON_ERROR` | Fail job on a request/test error | `true` |
| `NEWMAN_ITERATIONS_NUMBER` | Number of Newman iterations to run (see [documentation](https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/#misc)) | `2` |
+9 −2
Original line number Diff line number Diff line
@@ -2,11 +2,12 @@ stages:
  - dynamic_tests

newman:
  image: node:15.10.0
  image: node:15.12.0
  stage: dynamic_tests
  variables:
    NEWMAN_COLLECTION: "postman_collection.json"
    NEWMAN_GLOBALS_FILE: ""
    NEWMAN_ENVIRONMENT_FILE: ""
    NEWMAN_ADDITIONAL_OPTIONS: ""
    NEWMAN_JUNIT_REPORT: "newman-report.xml"
    NEWMAN_FAIL_ON_ERROR: "true"
@@ -15,13 +16,19 @@ newman:
    NEWMAN_JUNIT_VERSION: "1.1.1"
  script:
    - npm install -g newman@${NEWMAN_VERSION} newman-reporter-junitfull@${NEWMAN_JUNIT_VERSION}
    - if [[ ! -z ${NEWMAN_ENVIRONMENT_FILE} ]]; then
    -   NEWMAN_ADDITIONAL_OPTIONS+=" -e ${NEWMAN_ENVIRONMENT_FILE}"
    - fi
    - if [[ ! -z ${NEWMAN_GLOBALS_FILE} ]]; then
    -   NEWMAN_ADDITIONAL_OPTIONS+=" -g ${NEWMAN_GLOBALS_FILE}"
    - fi
    - if [[ ! ${NEWMAN_FAIL_ON_ERROR} == "true" ]]; then
    -   NEWMAN_ADDITIONAL_OPTIONS+=" --suppress-exit-code"
    - fi
    - newman run ${NEWMAN_COLLECTION} -r cli,junitfull --reporter-junitfull-export ${NEWMAN_JUNIT_REPORT} -n ${NEWMAN_ITERATIONS_NUMBER} ${NEWMAN_ADDITIONAL_OPTIONS}
    - |
      newman run ${NEWMAN_COLLECTION} -r cli,junitfull \
      --reporter-junitfull-export ${NEWMAN_JUNIT_REPORT} \
      -n ${NEWMAN_ITERATIONS_NUMBER} ${NEWMAN_ADDITIONAL_OPTIONS}
  artifacts:
    reports:
      junit: ${NEWMAN_JUNIT_REPORT}
+2 −0
Original line number Diff line number Diff line
* Add `NEWMAN_ENVIRONMENT_FILE` variable
* Update job image from `node:15.10.0` to `node:15.12.0`