(一).新建一个jenkins的windows节点
(二).在节点环境上部署newman的运行环境(dos窗口安装必须用管理员权限)
1.安装node.js,版本太低也不行
2.安装依赖及newman
npm install -g node-gyp
npm install --global --production windows-build-tools
npm install -g newman
npm install newman-reporter-html
report是生产报告用的
(三)配置node和npm的环境变量或者在jenkins节点中声明环境变量,此处采用的是在节点中声明
(四)导出postman接口工程文件放到节点运行指定的目录下并newman运行
(这个后续可以用gitlab作为仓库,放在仓库中)
newman run D:\postman\接口.postman_collection.json
--reporters cli,html,json,junit
--reporter-json-export jsonOut.json
--reporter-junit-export xmlOut.xml
--reporter-html-export htmlOut.html
(五)设置jenkins发邮件
<br>
<storong style="font-weight:bold;">【测试具体详情】:</strong><a href="http://ip:8080/jenkins/job/makedo-maven/$BUILD_NUMBER/testReport/">接口具体详情请点击这里</a>
<br>
(六)运行结果