postmanlabs / newman

Newman is a command-line collection runner for Postman
https://www.postman.com
Apache License 2.0
6.88k stars 1.17k forks source link

unable to run folder name with spaces through newman in CircleCI #3033

Open jagruthim opened 2 years ago

jagruthim commented 2 years ago

Newman Version - 5.2.0 Recently we made an update to newman cmd options to include folders in postman. The folders have spaces. Example: "Testing Newman" When we include folders with spaces, the report gets generated but its empty. It does not display all the specified folders. Initial changes done in .yaml file were -
NEWMAN_CMD_OPTIONS: '--folder Folders --folder Assets --folder Templates --folder Template --folder "Render Preset"'

In the report, it displays specified folders as " Specified Folders: Folders,Assets,Templates,Template,"Render " and is a empty report

Attached the screenshots of report

Screenshot 2022-10-28 at 2 23 03 AM
shubhbhargav commented 2 years ago

@jagruthim Looks like the folder command is passed on as a single argument to newman. Can you confirm that the single quotes ' are part of the command being used or not? In-case they are, removing them should make it work i.e.

newman run <...collection-json...> --folder Folders --folder Assets --folder Templates --folder Template --folder "Render Preset"

jagruthim commented 2 years ago

@shubhbhargav It works fine when we don't have the folders with spaces. Example: NEWMAN_CMD_OPTIONS: '--folder Folders --folder Assets --folder Templates --folder Template'

I tried removing the single quotes and see the same. Example: NEWMAN_CMD_OPTIONS: --folder Folders --folder Assets --folder Templates --folder Template --folder "Render Preset"

As there are multiple collections, we are using variables like below. newman run Postman_Collections/$COLLECTION_JSON $NEWMAN_CMD_OPTIONS -e Environments/$AUTOMATION_ENV --reporters htmlextra --reporter-htmlextra-export $COLLECTION_REPORT_HTML

Screenshot 2022-10-28 at 6 49 50 PM
shubhbhargav commented 2 years ago

Ah I think the issue is with the escaping of the space character. Assuming that you are running this command on linux based system, can you try escaping the space character?

NEWMAN_CMD_OPTIONS: --folder Folders --folder Assets --folder Templates --folder Template --folder Render\ Preset
jagruthim commented 2 years ago

@shubhbhargav I tried using the same command. In report, at specified folders it displays as Specified Folders: Folders,Assets,Templates,Template,Render\

Screenshot 2022-10-29 at 1 08 20 AM
shubhbhargav commented 2 years ago

Looks like some OS specific issue. I was running this command on MacOS.

Can you please let me know which OS you are using (in-case you are using a CI provider, do let us know)? Also as an alternate, can you also check if providing the command line arguments in-line work or not?

jagruthim commented 2 years ago

Initially ,as there were two collections, i was using in-line arguments. It worked fine. After we had multiple collections to run, to avoid the the same script multiple times, changed it to below. Example of gitlab-ci.yml added below. Changed to sample collections and values. variables: ENV_1: value: "qa-env-1-stage.postman_environment.json" description: "Provide an environment from - 'dev' or 'stage' or 'prod'" ENV_2: value: "qa-env-2-stage.postman_environment.json" description: "Provide an environment from - 'dev' or 'stage' or 'prod'"

workflow: rules:

stages:

.collection: variables: COLLECTION_JSON: '' COLLECTION_REPORT_HTML: '' NEWMAN_CMD_OPTIONS: '' AUTOMATION_ENV: '' image: name: postman/newman_alpine33 entrypoint: [""] script:

env_1_collection: extends: .collection variables: COLLECTION_JSON: 'env1_postman_collection.json' COLLECTION_REPORT_HTML: 'env1_report.html' AUTOMATION_ENV: $ENV_1 NEWMAN_CMD_OPTIONS: ''

env_2_collection: extends: .collection variables: COLLECTION_JSON: 'env2_postman_collection.json' COLLECTION_REPORT_HTML: 'env2_report.html' AUTOMATION_ENV: $ENV_2 NEWMAN_CMD_OPTIONS: '--folder Folders --folder Assets --folder Templates --folder Template --folder "Render Preset"'

report: stage: report script:

These collections are being run in gitlab pipelines. They use debian:buster-slim.

shubhbhargav commented 2 years ago

Thanks for the detailed info @jagruthim. Let us try reproducing it with a Gitlab set up and figure out how to fix it. In the meantime, can you use the in-line arguments?

jagruthim commented 1 year ago

@shubhbhargav thanks. I will use in-line arguments.