How to Integrate Postman with Your CI / CD Pipeline

Coding, Technology
Integrate Postman with CI/CD Pipeline

GitHub is a premium repository that is widely used by developers who are looking for a cloud solution to store and manage codes. This cloud-based service also tracks and controls any changes to the codes, an essential requirement as the project grows. When automation is the call of the day, GitHub Actions has the right solution. 

With GitHub Actions the developers can now automate, customize, test, and execute the codes in the GitHub repository without human involvement. 

Primarily, GitHub Actions is the medium where continuous integration or continuous delivery, or CI/CD pipeline run. Or in other words, GitHub Actions is the CI/CD service integrated with GitHub. Dignitas Digital focuses on adapting to demanding technologies that aren’t exercised usually. 

In this article, we will explore a recent development, i.e., CI/CD with Postman collection that Dignitas has gained experience in.

Postman is the tool where the APIs are stored. So, let us discuss how to create a pipeline, configure GitHub Actions integration, and how you can configure your postman collection with the CI/CD pipeline of GitHub Actions.

Creating pipeline in GitHub

The first thing that you need to ensure here is whether the pipeline has been created in the GitHub repository where the APIs are to be used. If not, then here is how you can do it,

  • Go to the repository.
  • Create a directory under the name .github/workflows to store the files of workflows. A workflow is defined in this directory and multiple workflows can exist in it at the same instance. Each of these workflows can perform a different set of tasks.
  • Add a YAML file to this directory.
  • Define the pipeline in the YAML file. The workflow is defined by the YAML syntax and it can be either triggered manually, triggered by an event, or by a defined schedule.
  • Once the file is pushed to the GitHub repository, the pipeline is created.

GitHub actions integration configuration

  • Select the APIs in the sidebar and open the API. Every API can be linked with one single CI project.
  • Go to Test and Automation and select it.
  • Select GitHub Actions present under Automate option.
  • After the GitHub Actions is selected, there will be a prompt asking to allow Postman to access the GitHub account. Once you have granted access, close the browser tab. Now, you can return to Postman.
  • To help with the identification of the integration in the later stages, enter a Nickname. There is an in-built pre-fill system for the Nickname field in Postman which you can easily edit.
  • Go to the field Choose your organization and select the required GitHub organization from the drop-down.
  • Then, go to the field Choose your repository to select the repository where the workflows are defined.
  • Click on the button Connect and you are done with the integration of GitHub Actions.

Configuring postman for GitHub actions CI/CD

Postman CLI and Postman API help in the execution of API tests. The API tests must be created in Postman belonging to part of the GitHub pipeline. As the first step, you need to ensure that the integration between GitHub Actions and APIs have been done (as given above). 

Then, you have to generate the code for Postman CLI configuration in Postman. Then this code has to be added in a YAML file in the directory of .github/workflows in the GitHub repository.

For each pipeline execution, the Postman CLI runs the API collections. These collections contain the tests and the execution results can be viewed in Postman. Now, let us go through the steps involved in the configuration of Postman and GitHub Actions.

Steps involved while generating configuration code for Postman CLI

  • Open the Postman API, go to Test and Automation and select it. 
  • Select View All Builds, present under the name of the repository.
  • Now, go to Configure Postman CLI option and select it. 
  • Here, you have to select a Collection that will run during the building of the pipeline. First, add the collection to the API as the test suite so as to make it available in the list. 
  • Now, you have to select the Operating system for the CI/CD pipeline.
  • Then, to copy the Postman CLI configuration you must select Copy Postman CLI Command. 

Steps involved while adding the Postman CLI configuration to the GitHub pipeline

  • Go to the .github/workflows directory in the GitHub repository, and create a new YAML file. Then edit the file for the next step.
  • Once you selected the edit option, add the copied Postman CLI configuration from Postman to the new YAML file.
  • For the next step, all instances of $POSTMAN_API_KEY must be replaced with a valid Postman API Key.
  • After selecting commit, you need to push the changes to the remote repository. A build will automatically start in GitHub.
  • Now, open the API and select Test and Automation if you want to view the test results in Postman.

 

Conclusion

Writing tests for APIs can be effectively done through CI/CD Postman Collections. Automating the CI/CD pipeline with GitHub Actions makes the entire process of developing, testing, and deploying codes much easier. It simplifies the process involving less human labor and error. 

Thus, making the workflow fast and super-efficient. The best part of it is that numerous other jobs like sharing or combining actions can be done seamlessly. In a nutshell, if you want to maintain the quality of the project during development then Postman is the answer which supports multiple CI/CD tools.

, , ,
Previous Post
Google Meet vs Zoom – Whom to Choose?
Next Post
FIFA World Cup 2022 and The Whopping Prize Money

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu