Jenkins is an open source automation server that can act as a continuous integration (CI) server or a continuous delivery (CD) hub. Use Newman to integrate your Postman tests with Jenkins. You can run a Postman Collection and its API tests from Jenkins. You can also specify the frequency that Jenkins runs a collection.
This guide uses a Jenkins installation that runs locally, but in most cases you'll run Jenkins on a build server in your production environment.
Developing an API? Postman offers built-in tools to integrate your API with some of the most popular continuous integration (CI) tools, including Jenkins. After you set up CI for your API, you can view the status of builds or kick off a new build, all from within Postman. You can also use Newman to run API tests as part of your CI pipeline. To learn more, see CI integrations.
Install Jenkins if you haven't already, and start it. By default, Jenkins is configured at http://localhost:8080
if you're running it locally. Install the NodeJS plugin in Jenkins, then install Newman in it.
To install NodeJS in Jenkins, do the following:
To install Newman in Jenkins, do the following:
newman
.After you install Newman in Jenkins, you can configure Jenkins to run a collection using Newman. You'll need a Postman Collection that has at least one request with tests. Then export the collection as a JSON file so you can run it using Newman.
Optionally, you can import a sample "Hello World" collection into your workspace to follow these instructions. Select the following Run in Postman button to import the collection.
To configure Jenkins to run Newman, do the following:
On the Dashboard page, select + New Item to create a new job.
Select Freestyle project from the options, name your project, and select OK.
On the Configure page, select Build Environment, and select the checkbox next to Provide Node & npm bin/ folder to PATH. Select the NodeJS installation where you installed Newman.
Select Build Steps, and select Add build step > Execute shell to run a shell command. Enter a shell command to run the collection using Newman, for example:
newman run ~/Desktop/jenkins_demo_postman_collection.json
Select Save.
On the Dashboard page, select the job you configured to run Newman.
Select Build Now to manually run the build. After the build runs, review the Build History to check if the build succeeded:
If the build succeeded, Jenkins indicates this with a green checkmark.
If the build failed, Jenkins indicates this with a red cross mark.
Select the build from the Build History, then select Console Output to review the results of the collection run.
If the build failed, go to the collection in Postman to fix your tests. Then export the collection as a JSON file, and run the build again.
You can configure Jenkins to run Newman at a specified frequency. This enables you to run and test collections from Jenkins on a schedule.
In your production environment, you can set up notifications and customize Jenkins to align with your organization's goals.
To set the frequency that Jenkins runs Newman, do the following:
On the Dashboard page, select the job you configured to run Newman.
Select Configure.
On the Configure page, select Build Triggers, then select the checkbox next to Build periodically.
Enter the schedule you'd like the build to run using cron syntax. For example, the following syntax sets the build frequency to every 15 minutes: H/15 * * * *
.
Select the help icon next to Schedule to learn how to specify the build frequency.
Select Save.
Last modified: 2024/09/16
Additional resources
Videos
Blog posts