Run Postman tests with Newman in Gitlab CI

for your integration testing

2 min readSep 1, 2018


In this article, let me show you how to run Postman tests in Gitlab CI/CD pipeline. Basically, we’re working with api and testing on web or client but in order to run Postman tests while pipeline progress, we need to use Newman which a runner to run and test a Postman collection from the command-line.

1. Generate an API Key

First, we have to get an Postman API Key, because it’s needed to get collection and environment url via Postman API for running tests with Newman.

Integrations > Postman API
  1. Go to web > Choose workspace > Tab ‘Integrations’
  2. Tab ‘Browse Integraions’ > Choose ‘Postman API’ > Click ‘+ Get API Key’
Take it!

2. Get the Collection URL

It takes two steps to get the collection url to test via Postman API with the API key. One step is that fetch a list of your collection and get a uid of the collection to test in the list. Last step is that get the collection url with the uid from previous step.

2.1 Fetch a collection list & Get a `uid` of the collection${apiKey}

2.2 Get the collection url${c_uid}?apikey=${apiKey}

3. Get the Environment URL

It’s the same as above getting the collection url.

3.1 Fetch a environment list & Get a ‘uid’ of the environment${apiKey}

3.2 Get the environment url${e_uid}?apikey=${apiKey}

4. .gitlab-ci.yml

Last, to run Postman test in Gitlab CI/CD, let’s add a job which call Newman ‘run’ command in the pipeline to the .gitlab-ci.yml. There are two cases whether based on docker or not. If without docker, it needs to install Newman in before_script. Otherwise, wojciechzurek/newman-ci docker image helps you not have to the install it.

Without docker

without docker

With docker

with docker



Recommended from Medium


See more recommendations