Commit 71ee3bb0 authored by Thomas Boni's avatar Thomas Boni Committed by Fulcrand Guilhem
Browse files

Resolve "[job][newman] Wrongly named variables"

parent a820b3dd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -68,4 +68,11 @@ 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_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 | `false` |
| `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` |

### Artifact

We use [Junit](https://junit.org/junit5/){:target="_blank"}'s XML report to
display error report directly in pipeline `Test` tab and in merge request
widget.
+7 −3
Original line number Diff line number Diff line
@@ -9,17 +9,21 @@ newman:
    NEWMAN_GLOBALS_FILE: ""
    NEWMAN_ADDITIONAL_OPTIONS: ""
    NEWMAN_JUNIT_REPORT: "newman-report.xml"
    NEWMAN_FAIL_ON_ERROR: "false"
    NEWMAN_FAIL_ON_ERROR: "true"
    NEWMAN_ITERATIONS_NUMBER: "2"
  script:
    - npm install -g newman newman-reporter-junitfull
    - if [[ ! -z ${NEWMAN_GLOBALS_FILE} ]]; then
    -   NEWMAN_ADDITIONAL_OPTIONS+=" -g ${NEWMAN_GLOBALS_FILE}"
    - fi
    - if [[ ! ${NEWMAN_EXIT_ON_ERROR} == "true" ]]; then
    - if [[ ! ${NEWMAN_FAIL_ON_ERROR} == "true" ]]; then
    -   NEWMAN_ADDITIONAL_OPTIONS+=" --suppress-exit-code"
    - fi
    - newman run ${NEWMAN_COLLECTION} -r junitfull --reporter-junitfull-export ${NEWMAN_JUNIT_REPORT} -n 2 ${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}
    paths:
      - ${NEWMAN_JUNIT_REPORT}
    when: always
    expire_in: 30 days
+5 −0
Original line number Diff line number Diff line
* Fix doubly named variable `NEWMAN_FAIL_ON_ERROR` (remove `NEWMAN_EXIT_ON_ERROR`)
* `NEWMAN_FAIL_ON_ERROR` default value is now `true`
* Allow specifying number of iterations through variable `NEWMAN_ITERATIONS_NUMBER` with 2 as default value
* Add the `cli` report in log output in addition to `junit`
* Add `junit` report as user-reachable artifact in addition to the report integration