将 Postman 测试脚本与 Jenkins 构建服务器集成 [英] Integrate Postman test scripts with Jenkins build server

查看:12
本文介绍了将 Postman 测试脚本与 Jenkins 构建服务器集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)JenkinsworkspaceWeb Api Test1 (Team Gecko)
[Web Api Test1 (Team Gecko)] $ "C:Program Filesinsh.exe" -xe C:WindowsTEMPhudson2522506155962538386.sh
+ newman -c C:Users
obertjmDocumentsPOSTMAN FilesWorkbench-API-Collection.json -n 3 -y 1000 --exitCode 1 -o output.json -H output.html
C:WindowsTEMPhudson2522506155962538386.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 newmanin:

  cd Usersobappdata
oaming
pm
ode_modules
ewmanin

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:usersob$appdata$ ).

I hope this helps someone in the future.

good luck.

这篇关于将 Postman 测试脚本与 Jenkins 构建服务器集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆