Hi Readers, In this blog, we will explore Postman with CircleCI. As we know that Postman is an API testing tool and CircleCI is a CI/CD tool so it is the best combination to integrate Postman with CircleCI.
Basically, there are some requirements to perform this process-
Install Postman into your system:- For Linux-
$ sudo apt update $ sudo apt install snapd $ sudo snap install postman
- Should have a CircleCI account:- For this, Signup into CircleCI–
2.Should have a Github account:-FOr this, Signup into Github-
Create a first postman collection:-
Postman collection is a folder where we keep all the APIs and easily make them maintain so these collections can be shared amongst the team in the Postman workspace so that we can share the collection with others easily.
How to create the first collection in the postman?
1:- Click on new to create a collection
2:- Click on Collection
3:- Enter any name
How to add requests?
In Postman, We can add multiple requests like- GET, POST, PUT, PATCH and DELETE. Here, we will take a simple get request. For further process follow these steps below-
1-Add a request.
2:- Enter the URL
3:- Add multiple assertions under the Tests tab.
4:- Add Environment variables.
5:- Download the collection into your local system.
Connect the project to CircleCI
There are a few steps to follow on how to connect with CircleCI-
1. Before connecting to CircleCI, we should have an account on Github or Bitbucket.
2. After that push your code into the Github repository.
3. Create an account on CircleCI.
4. Select any one of them either Github or Bitbucket.
5. All projects will be displayed in CircleCI which you have pushed on Github or Bitbucket.
6. After that, click on Project on the left side
7. Click on Set up
8. On the setup page, click Use Existing Config
9. Click Start Building.
Set up with Newman
It is a command-line Collection Runner for Postman to generate an HTML report. CircleCI has one feature to set up with Newman which is Orb so Orb is nothing, it is reusable snippets of code that help automate repeated processes, accelerate project setup, and make it easy to integrate with third-party tools. In CircleCI, we have to make changes in settings for Newman. Follow these steps below-
On the left side click on Organisation settings > select security > click on yes
After that create a folder named
.circleci at the root of the project and add a configuration file named
config.yml inside the folder. In this file, enter the following code:-
orbs: newman: email@example.com jobs: build: executor: newman/postman-newman-docker steps: - checkout - newman/newman-run: collection: ./Users.postman_collection.json environment: ./My-Remote-API-Testing.postman_environment.json
Commit your changes and push to the remote repository to trigger the pipeline build.
To follow all the above steps to connect Postman with CircleCI.With the help of it, we can generate a Newman report easily and share this with others also.
I hope you enjoyed it and it helped you!! stay connected for more future blogs.