Continuous Integration (CI) is a development practice that requires developers to regularly merge code updates into a shared repository. It involves the process of automating the build and testing of code every time a developer commits code updates.
Let’s access collections using the Postman API to run inside your Continuous Integration / Continuous Deployment (CI/CD) environments.
Before we get started:
You may skip this step if your CI already has Node installed.
Follow the steps to download Node which is specific to your CI’s platform. Otherwise, some CI has configuration which simply pre-installs Node. Ensure you are using NodeJS v4 or above.
Newman is a command-line tool that allows you to run a collection in your local development environment or on your own server. The following command installs Newman in your CI.
npm i newman -g;
Run the following Newman command with the appropriate parameters:
newman run https://api.getpostman.com/collections/{{collection_uid}}?apikey={{postman-api-key-here}}
If you need to provide an environment to the collection, change the above command to the following:
newman run https://api.getpostman.com/collections/{{collection_uid}}?apikey={{postman-api-key-here}} --environment https://api.getpostman.com/environments/{{environment_uid}}?apikey={{postman-api-key-here}}