Search code examples
apipostmannewman

Postman Collection is passing in Postman Runner but not It's failing in Command prompt and in Jenkins job


I am trying to run the Postman Collection JSON file in the CMD and in Jenkins. All the Test Scripts, null check validation, Schema Validation has been failing in CMD and in jenkins. The same Collection is passing in Postman's collection runner.

I have used Environment variables for the API Endpoint, credential and Authentication Token.

My Question - Are the Environment Variables mapped/recorded in the JSON Collection file during the Export? If not, then how do I map/record Environment variables within JSON Collection File?

enter image description here

enter image description here

FOR the Schema validation, Newman is unable to read/load the Scehema from git link.

enter image description here


Solution

  • It's not failing in the Collection Runner because you have selected the separate environment file in the UI. You can tell this from the title, at the top of the collection run summary.

    The environment variables are contained in a separate exportable file, you would need to get a copy of this from the 'Manage Environment' section of the application. More information about how to do this can be found here.

    To use the file in the command line using Newman, you need to use the -e argument followed by the environment file.

    For example:

    newman run <collection file> -e <environment file>

    All the CLI arguments can be found here on the documentation.