Integrate Postman test scripts with Jenkins build server
Final solution was :
1) Add build step "Execute Windows batch command" and add two lines below:
2) change dir to newman\bin:
cd \Users\bob\appdata\roaming\npm\node_modules\newman\bin
3) run node newman
as opposed to simply trying to run newman
node newman -c "C:\\Users\\bob\\Documents\\POSTMAN Files\\Workbench-API-Collection.json"
The two tricky parts were:
1) running newman like this newman -c myCollection.json
was not working, as Jenkins could not resolve this node module as it would in a straight Win cmd prompt.
2) Trying to locate the Newman module was difficult, as it's hidden inside %appdata%
folder (i.e. c:\users\bob\$appdata$ ).
I hope this helps someone in the future.
good luck.
Run command "which newman" in command prommpt. It will return something like - /c/Users/user1/AppData/Roaming/npm/newman
Now use fully qualified path returned by above mentioned command in Jenkins windows batch command box -
c:/Users/user1/AppData/Roaming/npm/newman -c demo.postman_collection.json
Integrate Postman with Jenkins on Windows Machine
Step #1 : Download Jenkins on your local windows machine .
URL to Download Jenkins :-- https://jenkins.io/download/ After successful download enter :- http://localhost:8080 Step #2 : Enter the name of the project and click on Freestyle project and save .
Step #3 : PostmanScriptTest2 job gets created and under source code management >build > click on execute windows batch command.
Step #3: Type in command under Execute Windows batch Command
C:\Users\ashish\AppData\Roaming\npm\newman run https://www.getpostman.com/collections/d231549a4assc77abcdbaf9c674
Click on save and apply.
Step #4: Go to Jenkins Home Page and click on Manage Jenkins
Step #5 : Under manage Jenkins click on configure System .
Step #6 : Under Global Properties > check on environmental variables and enter
Name - PATH
Value - C:\Program Files\Nodejs
Step #7 : Under Shell , shell executable type in C:\Windows\System32\cmd.exe and click on save and apply .