Using Newman you can run and test a Postman Collection. Newman and Jenkins can be used together run your collection through postman. To start you need to first install Newman and jenkins in your machine.

To install newman and run a postman collection using Newman you can follow my post Step by step Newman integration with Postman.
Once you have Newman installed you can download and install Jenkins from here.

Setting up Jenkins

Jenkins exposes an interface at http://localhost:8080.

Create a new job by clicking on the “New Item” link on the left sidebar > Select a “Freestyle Project” from the options > Name your project.

Add a build step in the project. The build step executes a Shell command.

Now , let say you have environment variables to set and get data from your postman environment variables . So when you are running through CLI you need pass the path of your environment varible JSON file.For example , the command you are running is below:

C:\Users\qatechtools>newman run https://www.getpostman.com/collections/fab95023445 -e
QA.postman_environment.json -r htmlextra,cli --insecure --export-environment QA.postman_environment.json

To break and understand this command , first download the environment variable file .It will be a json file and place it in any folder(preferably same as project location).

After you have download the file , lets understand the command

  1. First part consists of your postman collection
  2. Second “-e your_environment_variable_filepath”. -e parameter to denote kind of environmenr variable(global, local, etc).From this file your environment variables will be passed to your collection.
  3. Thrid paramater “–insecure” to turn of the SSL settings.
  4. Forth parameter “export-environment environment_variable_path .This file is where all you request data gets stored.

You can add --suppress-exit-code 1 , ”suppress-exit-code” uses the value 1. This denotes that Newman is going to exit with this code that will tell Jenkins that everything did not go well.