Running Postman Collection through Jenkins with a data file

I understand that we can run a collection manually with a selected local data file as input(JSON or CSV).
Can we achieve this in a similar manner , not manually , but via CLI / on a CI/CD pipeline ?

Hey @svazha :wave:

Welcome to the Postman Community! :postman:

There are a number of different ways that you can do this, one of the easest methods is to use the Postman CLI. Within the Collection Runner you will see an option to “Automate the runs via CI”, this has a section called “Run on CI/CD” at the bottom. Hit the “Generate command” link.

This will open a new tab and allow you to configure the command to include your Collection and Environment. Selecting the CI/CD Provider will create the command for Jenkins.

Another option is to use Newman and run the Collection using that command line runner in a Jenkins job.

This is a short tutorial by @vdespa, it’s a little dated now and their might be some changes to the UI in places but it should work for you.

With both methods, specfiying a datafile in the command would just be a case of using the --iteration-data or -d flag and then pass in the location of the file.

Appreciate the response , Danny - thank you . I will try this and see how it goes .

Hi Danny ,

I tried giving data input file with the -d as per your suggestion in Execute shell of Jenkins job :

newman run APIKey_Link_Of_Postman_collection.json -e github_Link_of_env.json -d github_Link_of_datafile.csv

This throws an error as below:

error: iteration data could not be loaded
Invalid Closing Quote: found non trimable byte after quote at line 38

Build step ‘Execute shell’ marked build as failure
Finished: FAILURE

Also , for another job which doesn’t require data file as below,

newman run APIKey_Link_Of_Postman_collection2.json -e github_Link_of_env.json

I got below error:

error: could not load environment
Unexpected token ‘<’ at 1:1


Build step ‘Execute shell’ marked build as failure
Finished: FAILURE

NOTE: Both these Collections above run fine in local (gitbash) and gives correct results

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.