Access Postman collections in your CI environment using Newman

You can use Newman and the Postman API to run Postman Collections in your continuous integration (CI) environments. You must first install Newman and Node.js, and then you can run Newman to get your collection using the Postman API.

Contents

Prerequisites for accessing collections in your CI environment

Before you get started, check the following prerequisites for accessing collections using Newman and the Postman API:

  • Ensure you have a CI system setup that can run shell commands and that you have access to modify.
  • Generate a Postman API key, and copy it for later use.
  • Make sure you have a Postman Collection that tests your localhost server, and copy the collection ID for later use. If your collection needs an environment, copy the environment ID for later use.

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 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.

Install Newman and Node.js

To learn how to install Newman and Node.js, see Install and run Newman.

You don't need to install Node.js if your CI environment already has it installed.

Run Newman and use the Postman API

To run Newman and use the Postman API to access your collections, run the following command:

$ newman run "https://api.getpostman.com/collections/collection-id?apikey=postman-api-key"

If you need to provide an environment to the collection, add the --environment option with the appropriate parameters to the Newman command:

$ newman run "https://api.getpostman.com/collections/collection-id?apikey=postman-api-key"
--environment "https://api.getpostman.com/environments/environment-id?apikey=postman-api-key"

Last modified: 2023/10/05