I've downloaded the POSTMAN Chrome app in order to test some Web APIs on my local dev environment.
In addition, I've downloaded the Newman cmd-line utility for Postman.
See https://www.getpostman.com/docs/newman_intro for more info.
So the Postman app is working fine, and the cmd-line utility is working too.
However, once I integrate it with my Jenkins test server, the tests are failing.
The main problem is that it's not able to launch Newman
.
In a standard cmd prompt, I can successfully run the Newman test script as :
newman -c API-Collection.json -n 3
running n number of times.
And in the Jenkins
build server GUI, I add the build script under the "Execute Shell" option.
But it doesn't find Newman
, as this build error shows:
FailedConsole Output
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Web Api Test1 (Team Gecko)
[Web Api Test1 (Team Gecko)] $ "C:\Program Files\bin\sh.exe" -xe C:\Windows\TEMP\hudson2522506155962538386.sh
+ newman -c C:\Users\robertjm\Documents\POSTMAN Files\Workbench-API-Collection.json -n 3 -y 1000 --exitCode 1 -o output.json -H output.html
C:\Windows\TEMP\hudson2522506155962538386.sh: newman: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
If someone can assist me in resolving this path issue, I would appreciate it.
thanks, Bob
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With