Integrate Postman with CircleCI

CircleCI is a cloud-based continuous integration and continuous delivery (CI/CD) platform. Software development teams use CircleCI to run build jobs, automate tests, and orchestrate complex workflows.

To set up CircleCI integration for your API, first create an API token in CircleCI and then configure your API in Postman. After you set up the integration, you can view the status of builds or start a new build, all from within Postman.

Creating a CircleCI API token

  1. Sign in to CircleCI and go to User Settings > Personal API Tokens.
  2. Select Create New Token.
  3. Enter a Token Name and select Add API Token.
  4. Select Copy to copy the new token. (Save the token somewhere safe.)

Configuring a CircleCI integration

  1. Open your API by selecting APIs in the sidebar. Each API can be linked to one CI project.
  2. Select Test and Automation.
  3. Under Automate, select CircleCI.
  4. Enter a Nickname to help you recognize the integration later.
  5. For API Key, enter your CircleCI token.
  6. Select the CI project used for your API.
  7. Select Connect.
Connect to CircleCI

Viewing build status

After you set up a CircleCI integration, status information for build jobs is available in Postman. For each build you can view the commit message, the branch the build ran on, the start time and duration, and the build status (Success or Failed).

To view build jobs, open an API and select Test and Automation. The most recent jobs are listed under the repository name.

Select View All Builds to view the full list of build jobs. From here you can take the following actions:

  • Use the dropdown lists to filter jobs by branch or build status.
  • To open a build in CircleCI, select the build name.
  • To start a new build, select Run Build. Select or enter the name of the branch to use and select Run Build.
  • To get the latest build status information, select Refresh icon Refresh.
  • To edit or delete the integration, select the more actions icon More actions icon.
View all CircleCI builds

Viewing collection run details

Using the Postman CLI, you can run Postman collections with your API tests as part of a CircleCI pipeline.

To view details for collections that were run as part of a build, first configure the Postman CLI for CircleCI and then start a new build. After the build is complete, use the arrows to expand a build and expand a collection to view details about a collection run.

Select View Report to view a collection run report in the Postman History. Learn more about using the Collection Runner.

Viewing API Governance and API Security rule violations

Using the Postman CLI, you can enforce Postman API Governance and API Security rules each time the pipeline runs using the api lint command (Enterprise teams only).

To view the results of API Governance and API Security checks that ran as part of the build, first configure the Postman CLI for CircleCI and then start a new build. After the build is complete, use the arrows to expand a build and expand an API definition to view any rule violations.

View API Governance and API Security results

Configuring the Postman CLI for CircleCI

With the help of the Postman CLI and the Postman API, you can run Postman collections with your API tests as part of your CircleCI pipeline. First generate the Postman CLI configuration code in Postman. Then add the configuration code to the config.yml file in your CircleCI project.

You an also enforce API Governance and API Security rules each time the pipeline runs (Enterprise teams only).

To generate configuration code for the Postman CLI, do the following:

  1. Open your API and select Test and Automation.
  2. Under the repository name, select View All Builds.
  3. Select Configure Postman CLI.
  4. Select a Collection to run during pipeline builds. To be available in the dropdown list, you must first add the collection as a test suite to your API. You can also select an Environment to use.
  5. (Optional) Select the checkbox to enforce API Governance and API Security rules each time the CI/CD pipeline runs (Enterprise teams only).
  6. Select the Operating system for your CI/CD pipeline.
  7. Select Copy Postman CLI Command to copy the Postman CLI configuration.
Generate the Postman CLI configuration

To add the Postman CLI configuration to your CircleCI project, do the following:

  1. Open your project in CircleCI, select a branch, and then select Edit Config.
  2. Paste the Postman CLI configuration you copied from Postman:
    • Replace all instances of $POSTMAN_API_KEY with a valid Postman API Key.
    • Make sure to add the postman-automated-runs job to a new or existing workflow.
  3. Select Save and Run to run the pipeline using the new configuration.
  4. To view the test results in Postman, open your API and select Test and Automation.

Last modified: 2022/09/15