Archived documentation version rendered and hosted by DevNetExpertTraining.com

CI with Postman API

Continuous Integration (CI) is a development practice that requires developers to regularly merge code updates into a shared repository. It involves the process of automating the build and testing of code every time a developer commits code updates.

Let's access collections using the Postman API to run inside your Continuous Integration / Continuous Deployment (CI/CD) environments.

Before you get started:

  • Ensure you have a CI system setup which can run shell commands and that you have access to modify the same.
  • Get a Postman API key. If you don't have one, you can generate an API key.
  • Make sure you have a Postman Collection that tests your localhost server, and note the UID of the collection.

Developing an API? Postman offers built-in tools to integrate your API with some of the most widely-used Continuous Integration (CI) tools. After you set up CI integration for your API, you can view the status of builds or kick off a new build, all from within Postman. You can also use Newman to run API tests as part of your CI pipeline. To learn more, see CI integrations.

Step 1: Install Node

You may skip this step if your CI already has Node installed.

Follow the steps to download Node which is specific to your CI's platform. Otherwise, some CI has configuration which simply pre-installs Node. Ensure you are using NodeJS v4 or above.

Step 2: Install Newman

Newman is a command-line tool that allows you to run a collection in your local development environment or on your own server. The following command installs Newman in your CI.

npm i newman -g;

Step 3: Run Newman

Run the following Newman command with the appropriate parameters:

newman run https://api.getpostman.com/collections/{{collection_uid}}?apikey={{postman-api-key-here}}

If you need to provide an environment to the collection, change the above command to the following:

newman run https://api.getpostman.com/collections/{{collection_uid}}?apikey={{postman-api-key-here}}
--environment https://api.getpostman.com/environments/{{environment_uid}}?apikey={{postman-api-key-here}}

Last modified: 2022/03/01