In this post, we’ll explain the API integration testing solution step by step using Postman, Newman, and Jenkins Pipeline.
This post shows how to set up a Jenkins pipeline that uses Newman to run a Postman collection.
Prerequisites
This is the list of all the prerequisites for following this story:
- A GitHub repository
- Git
- Jenkins instance installed
- Node JS
- NPM
- Postman
Overview
What is Postman?
Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs — faster.
What is Newman?
Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.
What is Jenkins?
Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.
Getting started
1- Postman collection
Open postman -> File -> New -> Collection

Then, inside the collection, we will create the different requests that we want to test on our API. For this post, we will use the fake “JSONPlaceholder” API endpoints.

With Postman we can add scripts to each request. Testing confirms that our API is working as expected, integrations between services are working reliably, and changes have not broken existing functionality.
The Pre-Request Script tab will run before our request is sent, and the Tests tab will run after we receive our response.

Tests are scripts written in JavaScript that are executed after a response is received. Tests can be run as part of a single request or run with a collection of requests.

pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response fields", function () {
var jsonData = pm.response.json();
pm.expect(jsonData).to.be.an("object");
pm.expect(jsonData.id).to.an("number");
pm.expect(jsonData.userId).to.an("number");
pm.expect(jsonData.title).to.an("string");
pm.expect(jsonData.body).to.an("string");
});
pm.test("Equal value", function () {
const jsonData = pm.response.json();
pm.expect(jsonData.id).to.eql(1);
pm.expect(jsonData.userId).to.eql(1);
});
In order to run a collection with Newman, we need to export it from Postman

2- Set up Jenkins
- Install globally newman and newman-reporter-htmlextra packages
npm install -g newman
npm install -g newman-reporter-htmlextra
- Create a new pipeline project
With Jenkins running, On the Dashboard page, select New Item on the left sidebar to create a new job.
Select Pipeline from the options. Name your project, and select OK.

On the job configuration page, we will add the pipeline script below:
pipeline {
agent any
stages {
stage('Clean Workspace'){
steps {
cleanWs()
}
}
stage('Checkout'){
steps {
checkout([$class: 'GitSCM',
branches: [[name: '*/main']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/anicetkeric/postman-newman-jenkins.git']]])
}
}
stage('run Test newman') {
steps {
sh 'newman run JSON-Placeholder.postman_collection.json --reporters cli,junit,htmlextra --reporter-junit-export "newman_result.xml" --reporter-htmlextra-export "newman_result.html" '
junit "*.xml"
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: '.',
reportFiles: 'newman_result.html',
reportName: 'Newman HTML Reporter'
]
}
}
}
}
Don’t forget to replace the GitHub repo link with your own in the pipeline script.
- Select Save to finish creating the job.
Let’s run this build test manually by clicking on the “Build Now” link in the sidebar.



All done.
If you enjoyed this article, please give it a few claps for support.
Thanks for reading!
The sample code is available on GitHub.