第二步:在nodejs命令行安装newman,即命令行输入如下命令:
shifangfangdeMacBook-Pro:~ shifangfang$ npm install -g newman-reporter-html
npm WARN invalid config registry=""
npm WARN invalid config Must be a full url with 'http://'
/usr/local/lib
├── UNMET PEER DEPENDENCY newman@4
└── newman-reporter-html@1.0.2
npm WARN newman-reporter-html@1.0.2 requires a peer of newman@4 but none was installed.
PS、使用newman运行json脚本
比如:
shifangfangdeMacBook-Pro:~ shifangfang$ newman run /Users/shifangfang/Desktop/pro_env_order.postman_collection.json -e /Users/shifangfang/Desktop/pro_env.postman_environment.json --reporters html --reporter-html-export /Users/shifangfang/Desktop/result-order.html --export-environment /Users/shifangfang/Desktop/
4、jenkins创建freestyle job
[attach]123870[/attach]
[attach]123871[/attach]
[attach]123872[/attach]
[attach]123874[/attach]
PS:shell命令---html报告名称前最好加个编号,不然多次最新会一直覆盖看不到之前生成newman run /Users/Shared/Jenkins/Home/workspace/pro_env_order/pro_env_order.postman_collection.json -e /Users/Shared/Jenkins/Home/workspace/pro_env_order/pro_env.postman_environment.json --reporters html --reporter-html-export /Users/Shared/Jenkins/Home/workspace/pro_env_order/result-order$BUILD_NUMBER.html
4.1、构建
PS:执行构建任务发现报错,报错信息
/Users/Shared/Jenkins/tmp/jenkins5552974125428727684.sh: line 2: newman: command not found
Build step 'Execute shell' marked build as failure