- Introduction
- Installing and updating
- Navigating Postman
- Sending your first request
- Managing your account
- Syncing your work
- Discovering templates
- Creating your first collection
- Creating a workspace
- Setting up your Postman app
- Importing and exporting data
- Troubleshooting app issues
- Building requests
- Authorizing requests
- Receiving responses
- Grouping requests in collections
- Using variables
- Managing environments
- Visualizing responses
- Specifying examples
- Using cookies
- Working with certificates
- Generating client code
- Troubleshooting requests
- Using the Collection Runner
- Scheduling runs with monitors
- Building request workflows
- Importing data files
- Working with your team
- Defining roles
- Requesting access
- Sharing your work
- Your Private API Network
- Commenting on collections
- Versioning APIs
- Using version control
- Using the API Builder
- Managing and sharing APIs
- Validating APIs
- Monitoring your APIs
- Setting up a monitor
- Viewing monitor results
- Monitoring APIs and websites
- Set up integrations to receive alerts
- Running Postman monitors using static IPs
- Troubleshooting monitors
- Monitoring FAQs
- Analyzing with reports
- Documenting your API
- Authoring your docs
- Publishing your docs
- Viewing documentation
- Using custom domains
- Publishing templates
- Publishing to the API Network
- Submission guidelines
- Managing your team
- Purchasing Postman
- Billing
- Configuring team settings
- Utilizing audit logs
- Onboarding checklist
- Migrating data between teams
- Intro to SSO
- Configuring SSO for a team
- Logging in to an SSO team
- Microsoft AD FS
- Custom SAML in Azure AD
- Custom SAML in Duo
- Custom SAML in GSuite
- Custom SAML in Okta
- Custom SAML in Onelogin
- Custom SAML in Ping Identity
- Migrating to the current version of Postman
Integrating with Jenkins
Postman contains a full-featured testing sandbox that lets you write and execute JavaScript based tests for your API. You can then hook up Postman with your build system using Newman, the command line collection runner for Postman.
Newman allows you to run and test a Postman Collection. Newman and Jenkins are a perfect match. Let's review these topics to set up this operation.
- Installation
- Run a collection in Postman
- Run a collection using Newman
- Set up Jenkins
- Troubleshooting
- Configure frequency of runs
Note: This walkthrough uses Ubuntu as a target OS, as in most cases your CI server will be running on a remote Linux machine.
Installation
Install NodeJS and npm. Newman is written in NodeJS and the official copy is available through npm. Install nodejs and npm for Linux.
Install Newman globally, to set up Newman as a command line tool in Ubuntu.
$ npm install -g newman
Run a collection in Postman
These instructions assume you already have a Postman Collection with some tests. Run the collection in Postman. Here's an example of the output in Postman’s collection runner.
Some of the tests are failing intentionally in the screenshot to demonstrate the troubleshooting process.
Run a collection using Newman
Run this collection inside Newman, using the command below. If everything is set up nicely, you should see the output below.
Set up Jenkins
Jenkins exposes an interface at http://localhost:8080
.
Create a new job by clicking on the “New Item” link on the left sidebar > Select a “Freestyle Project” from the options > Name your project.
Add a build step in the project. The build step executes a Shell command.
Here is the command:
$ newman run jenkins_demo.postman_collection --suppress-exit-code 1
Note here that the Newman command parameter ”suppress-exit-code” uses the value 1
. This denotes that Newman is going to exit with this code that will tell Jenkins that everything did not go well.
Click the Save button to finish creating the project.
Troubleshooting
Run this build test manually by clicking on the “Build Now” link in the sidebar.
Jenkins indicates that the build has failed with a red dot in the title. You can check why with the console output from Newman.
Click the “Console Output” link in the sidebar to see what Newman returned.
Fix these tests inside Postman and then try again.
You can move on once you see green pass icons for all your tests like the screenshot above.
Jenkins indicates that the build succeeded with a blue ball.
Configure frequency of runs
To set up the frequency with which Jenkins runs Newman, click on “Configure project” in the main project window and then scroll down.=. The syntax for setting the frequency is H/(30) * * * *
.
Note: 30 can be replaced with another number.
Jenkins will now run Newman at your desired frequency and will tell you whether the build failed or succeeded. In a bigger setup, Newman will be part of your build process and probably not the entire process. You can set up notifications and customize Jenkins as per your needs.
You can use a wide variety of other configurations to make your collection more dynamic.
For more information about collection runs, see: