6

Running postman collections using Newman in Jenkins

 3 years ago
source link: https://blog.knoldus.com/running-postman-collections-using-newman-in-jenkins/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Reading Time: 3 minutes

We can write the automation test suite for any service which can be used for performing regression testing. But we can also integrate our automation test scripts using Newman in Jenkins CI/CD pipeline which can be triggered automatically whenever a pull request gets merged.

We need software installed on our system locally:

  • Jenkins
  • Postman (For writing the collection)

Files for execution

  • Firstly create a postman collection that is to be run using Newman and store it in a folder.
  • Now check-in your collection into your git repository. We need the link to the git repository which we will use in the further steps.

Setting up Jenkins pipeline

  • Now start your local jenkins with command:
systemctl start jenkins
  • After logging in go to new item.
  • Give a name to you project, select freestyle project and click OK.
  • Scroll down to Source Code Management section of the page and select git.
  • Enter the link to your git repository
  • If you are using an private repository you can add you credentials.
Screenshot-from-2020-05-01-00-10-36-1024x450.png

Go to buld section, click on add build step and select execute shell.

Screenshot-from-2020-05-01-00-24-33.png?fit=640%2C281&ssl=1
  • Write the Newman command to execute your postman collection.
Screenshot-from-2020-05-01-00-46-29.png?fit=640%2C278&ssl=1
newman run Mycollection.postman_collection.json
  • Click on save, go to your newly created project and click on ‘build now’
Screenshot-from-2020-05-01-00-47-38.png?fit=640%2C278&ssl=1
  • Click on the running build and click on console output.
Screenshot-from-2020-05-01-00-48-24.png?fit=640%2C274&ssl=1
Screenshot-from-2020-05-01-00-48-51.png?fit=640%2C280&ssl=1
  • Here we can see the result of our current test run. That how many tests failed or passed and also shows if the build is successful or not.

So this was a small introduction on how to execute postman collection with Newman in Jenkins. It is very helpful for CI/CD while development of services.

blog-footer.jpg

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK