linux+jenkins+postman持续集成

环境搭建:linux上安装newman,部署好jenkins linux上war包方式安装Jenkins

以下实现jenkins上执行postman测试脚本:

1.新建一个自动风格的job

2.构建-增加构建步骤-执行shell

source /etc/profile

cd /home/postman_script
newman run v3.x审方-0-用户登录和开始审方.postman_collection.json -e 10.1.1.71.postman_environment.json --reporters cli,json,html,junit --reporter-json-export report-json.json --reporter-html-export report-html.html --reporter-junit-export report-xml.xml

如果不是从git拉代码,同时需要注意index.html文件路径

newman run v3.x审方-0-用户登录和开始审方.postman_collection.json -e 10.1.1.71.postman_environment.json -r html --reporter-html-export /var/jenkins_home/workspace/test/htmlreports/index.html

注:需要将postman脚本事先上传到服务器

[root@ipha-dev71-1 postman_script]# cd /home/postman_script/     # postman脚本所在路径
[root@ipha-dev71-1 postman_script]# ll
total 8
-rw-r--r-- 1 root root  372 Aug 10 23:13 10.1.1.71.postman_environment.json
-rw-r--r-- 1 root root 3294 Aug 10 23:13 v3.x审方-0-用户登录和开始审方.postman_collection.json

3.查看构建结果

以下步骤非必须

4.将测试结果以文件格式保存(需安装插件HTML Publish)

构建后操作-增加构建后操作步骤-Publish Html Reports

HTML directory to archive 填写相对于工作空间的html报告所在的目录,需要填写真实存在的目录名称(如上图中的reports,需要自己事先创建,否则构建时会报错)

Index page[s] 报告目录中提供链接的文件,需要填写一个已经存在的html文件

Report title 报告标题

原文地址:https://www.cnblogs.com/wang-mengmeng/p/11333259.html