How to Run Postman Scripts from Newman CLI Commands
Last Updated :
23 Jul, 2025
Postman is an API development tool that allows developers to create, test, and manage APIs effortlessly. This helps in simplifying the testing and validation of APIs during the development process. In simple terms, it is an API that acts as a bridge that allows the different applications to communicate with each other. And one of the major key features is automated testing where developers can create scripts to validate API responses automatically. In this tutorial, we will see how to run Postman collections using Newman CLI (Command Line Interface).
Prerequisites
- Node.js installed in your system
- Having Knowledge about how API works
- Knowledge about Postman.
- Knowledge about Jenkins.
Creating a Postman Collection
Step 1: Head to the Postman Application and create a new workspace or use the existing workspace as per your requirement. Then navigate to the workspace be in the collections tab and click on the '+' symbol on the right of your page as shown below:
.jpg)
Step 2: Click on '+' and then choose and then choose 'Blank Collection' and then name the collection and add the requests as per your requirement.
Exporting Postman Collection
Step 1: After creating the requests successfully in your collection we need to download the collection to our local system.
Step 2: To download the collection click on three dots which is beside your collection name and scroll down you see the option 'Export' as shown below, and then a dialog box appears choose the version of your collection according to your requirement and click on export and you can see the collection as downloaded successfully.
.jpg)
Installing Newman
Step 1: To run Newman, make sure your system has Node.js installed. To check that open your command prompt and run the below command. If it returns the version as shown in the below image proceed to the further steps else Check here for installation.
node --version

Step 2: After successful installation of Node.js be on the same command prompt window and run the below command to install Newman CLI
npm install -g newman
Running Postman Scripts with Newman CLI
Step 1: Now open the local terminal and run the below command
newman run <File_Path_here>
Step 2: After the successful execution of the API request you will get the output screen as shown below it may vary based on your collection. Make sure that you are not using any environment variables.

Command-line Options and Configuration
Command | Usage |
---|
newman run <file_path> | This command is used to execute API tests which we have exported to our local system |
---|
newman run <Collection_file_path_here> -e <environment_file_path_here>
| Executes a collection in a specified environment |
---|
newman run <Collection_file_path_here> -g <path>
| This command is used to run API tests and apply global variables used in that collection |
---|
newman run <file_path> -n<number_of_iterations>
| Used to run the collection n times |
---|
newman run <file_path> --delay-request <time_of_delay>
| Used to Configure delay time in between requests |
---|
Running Collections with Global and Local Environments
Step 1: Follow the same above-mentioned steps additionally you need to download the global environment to your local system before exporting the environment make sure that the variable value is in 'initial value' and on the right corner you see the option 'Export' as shown in the image and simply click on that the environment will be downloaded to your local system.
.jpg)
Step 2: After that run the below command in your terminal to run the API request and you can see that the API request is successfully executed as shown below.
newman run <Collection_file_path_her> -g <global_environment_file_path_here>

Step 3: The same goes for the local environment. Download the local environment as shown below:
Step 4. Run the below command in your terminal to run the API request and you can see that the API request is successfully executed as shown below:
newman run <Collection_file_path_her> -e <environment_file_path_here>

Automating Postman Tests with Continuous Integration using Jenkins
Step 1: First make sure your system has Jenkins installed if not install Jenkins by using this guide. Then start the Jenkins server by running the below command and make sure you are in the correct directory before running the command.
java -jar Jenkins.war --httpPort=8080
Step 2: Open up your browser to open http://localhost:8080/ and enter your credentials and click on '+ New Item' and enter the name as per your requirement for this we can go with the freestyle project as shown below and click on OK it takes a few seconds to create a project.

Step 3: On the next page just scroll down to the build section and under build steps click on 'Add build step' and choose 'Execute Windows batch command' as shown below:
.png)
Step 4: Enter the newman run command as given in the below format make sure that the path from your local system is copied correctly and click on save to save the command.
newman run <File_Path_here>
Step 5: Just click on 'Build Now' and it takes time to build the project and you can see the output under the Console Output as shown below:

Troubleshooting and Best Practices
- While writing the command in the Jenkins project make sure that you copy the correct path of the file and write it else at the stage of building your project you will not get the expected output.
- Double-check all file paths (i.e., collection, environment, global environment) used in the Newman command's incorrect path may lead to errors.
- If your collection uses environment or global variables, confirm they are properly defined and exported.
- You can include logging commands like -r cli,json to note detailed results for analysis and a y troubleshooting issues.
- Keep your postman collection and scripts under version control to track the changes and ensure consistency across builds and regularly review your automated tests to ensure optimized performance.
Conclusion
In conclusion, running Postman scripts from the Newman CLI command provides an efficient way to automate the testing of APIs and also it enables the developers/users to execute the API test collection without the need for GUI (Graphical User Interface).
Similar Reads
Software Testing Tutorial Software testing is an important part of the software development lifecycle that involves verifying and validating whether a software application works as expected. It ensures reliable, correct, secure, and high-performing software across web, mobile applications, cloud, and CI/CD pipelines in DevOp
10 min read
What is Software Testing? Software testing is an important process in the Software Development Lifecycle(SDLC). It involves verifying and validating that a Software Application is free of bugs, meets the technical requirements set by its Design and Development, and satisfies user requirements efficiently and effectively.Here
11 min read
Principles of Software testing - Software Testing Software testing is an important aspect of software development, ensuring that applications function correctly and meet user expectations. From test planning to execution, analysis and understanding these principles help testers in creating a more structured and focused approach to software testing,
3 min read
Software Development Life Cycle (SDLC) Software Development Life Cycle (SDLC) is a structured process that is used to design, develop, and test high-quality software. SDLC, or software development life cycle, is a methodology that defines the entire procedure of software development step-by-step. The goal of the SDLC life cycle model is
8 min read
Software Testing Life Cycle (STLC) The Software Testing Life Cycle (STLC) is a process that verifies whether the Software Quality meets the expectations or not. STLC is an important process that provides a simple approach to testing through the step-by-step process, which we are discussing here. Software Testing Life Cycle (STLC) is
7 min read
Types of Software Testing Software testing is a important aspect of software development life-cycle that ensures a product works correctly, meets user expectations, and is free of bugs. There are different types of software testing, each designed to validate specific aspects of an application, such as functionality, performa
15+ min read
Levels of Software Testing Software Testing is an important part of the Software Development Life Cycle which is help to verify the product is working as expected or not. In SDLC, we used different levels of testing to find bugs and errors. Here we are learning those Levels of Testing in detail.Table of ContentWhat Are the Le
4 min read
Test Maturity Model - Software Testing The Test Maturity Model (TMM) in software testing is a framework for assessing the software testing process to improve it. It is based on the Capability Maturity Model(CMM). It was first produced by the Illinois Institute of Technology to assess the maturity of the test processes and to provide targ
8 min read
SDLC MODELS
TYPES OF TESTING