My .gitlab-ci.yaml file v
stages:
- test
postman_tests:
stage: test
image:
name: postman/newman_alpine33
entrypoint: [""]
script:
- newman --version
- npm install -g newman-reporter-junitfull
- npm install -g newman-reporter-junitxray
- apk add --update curl && rm -rf /var/cache/apk/*
- newman run https://api.postman.com/collections/25618800-2d1d5da6-05f3-4d88-88d1-faebffca89f7?access_key=PMAT-01GTVPN0MGG60TY1EX9G4JTFEH -r 'cli,junitfull,junitxray' --reporter-junitfull-export postman_echo_junitfull.xml
- export token=$(curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"$client_id\",\"client_secret\": \"$client_secret\" }" https://xray.cloud.getxray.app/api/v2/authenticate| tr -d '"')
- echo $token
- 'curl -H "Content-Type: text/xml" -X POST -H "Authorization: Bearer $token" --data @"postman_echo_junitfull.xml" https://xray.cloud.getxray.app/api/v2/import/execution/junit?projectKey=TSTXR&testPlanKey=${TESTPLAN}'
artifacts:
when: always
paths:
- postman_echo_junitfull.xml
For line below I get an error (red underline) about "Nested mappings are not allowed in compact mappingsYAML(0)" and "Incorrect type. Expected "string | array".yaml-schema: https://gitlab.com/assets/webpack/ci.030957f4.json"
export token=$(curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"$client_id\",\"client_secret\": \"$client_secret\" }" https://xray.cloud.getxray.app/api/v2/authenticate| tr -d '"')
Could someone please help and correct it for me as I don't know where the issue is
xxxxxxxxxxxxxxxxxxxx
The YAML syntax is giving you trouble here. Because your string contains a literal colon character (:
) you're accidentally creating a key-value (key: value
) mapping in YAML. To avoid this, you should use quotes around your script item to explicitly make sure it is interpreted as a string. You'll also need to escape the inner quotes.
For example, wrap the line in single quotes ('
) and then the literal single quotes within your string need to be escaped by prefixing them with another single quote -- ''
within a single-quoted string is interpreted to be a single literal quote ('
). Like this:
script:
# ...
- 'export token=$(curl -H "Content-Type: application/json" -X POST --data "{ \"client_id\": \"$client_id\",\"client_secret\": \"$client_secret\" }" https://xray.cloud.getxray.app/api/v2/authenticate| tr -d ''"'')'
# ...