Integration of Postman with CI/CD tool- CircleCI

Reading Time: 3 minutes

What is CircleCI

CircleCI is a modern continuous integration and continuous delivery (CI/CD) platform. The CircleCI Enterprise solution is installable inside your private cloud or data center and is free to try for a limited time. CircleCI automates the build, test, and deployment of Software.

From this above diagram, we came to know that after the test/code on GitHub is authorized and added as a project to circleci.com, every code change triggers automated tests in a clean container or VM. 

  • CircleCI runs each job in a separate container or VM. That is, each time your job runs CircleCI spins up a container or VM to run the job in.
  • So circleci job is basically the config file, we have to set the config file for each job.

This Config file of circle CI is in Yaml and these are the headers we need to build the config file.

  • Version(CircleCi version of configuration key)
  • orbs (orbs are open-source and help you integrate with your software and services stack quickly and easily )
  • commands (It defines a sequence of steps as a map to be executed in a job, enabling you to reuse a single command definition across multiple jobs.)
  •  parameters (parameters declared for use in the configuration)
  • executors (Executors define the environment in which the steps of a job will be run, allowing you to reuse a single executor definition across multiple jobs.)
  • jobs(Jobs are collections of steps. All of the steps in the job are executed in a single unit, either within a fresh container or VM.)

So these are the headers we need to pass in the config file of the circle to create Jobs.

Integration with Postman

To integrate the postman collection with CircleCI, we need to create the config file in YAML. Before that, we have to export the postman collection from Postman and saved in your repository

  • We need to add the version first
  • Then we will add orb stanza to import orb for Newman as per the version.
  • Further, we will add jobs, executor steps, and commands of Newman to run the collection.

So this is what your CircleCI config would look like with integration of postman collection:

version: 2.1

orbs:
  newman: postman/newman@0.0.2

jobs:
  newman-collection-run:
    executor: newman/postman-newman-docker
    steps:
      - checkout
      - newman/newman-run:
          collection: ./CircleCI.postman_collection.json
          environment: ./environment.json
          additional-options: -r cli,junit

workflows:
  version: 2
  Some Random Workflow:
    jobs:
      - newman-collection-run

The newman/newman-run command takes on a lot of arguments that are passed on to Newman. Here are some of the important parameters.

  • collection: This is the only required parameter as shown in the example above. It takes a path to a collection’s JSON file or a URL where the collection can be accessed.
  • environment: This needs either a path to an environment exported from Postman or a URL to the environment.
  • iteration-data: If you need to use external data from CSV files in your collection run, this argument takes the file path or URL to a CSV file.
  • folder: The name or names of folders to run in the collection. This is used when you want to scope your collection run to specific folders in the collection.

Similarly, we have a lot of arguments for Newman to use. Now it’s time to execute the build. So after executing the build pipeline in circle CI, it will look like as-

And the steps of collection run results are with all details as .

Newman collection results with report will look like as-

References

https://circleci.com/developer/orbs/orb/postman/newman
https://circleci.com/docs/2.0/local-cli/

Knoldus-blog-footer-image

Written by 

Aditi is Sr. Software Consultant -QA having experience of 3 years in Software Testing. She is familiar with API Testing & Performance Testing Using the tools like Jmeter,Postman, ReadyAPI(SoapUI),LoadUI are her expertise .Also having Knowledge of core concepts of manual and automation both as basic of Selenium Webdriver.She is always ready to adopt any environment and zeal to learn the new tools & technologies

Leave a Reply