1、在postman上創(chuàng)建項(xiàng)目
postman入門使用教程參見http://www.reibang.com/p/4d380f1a3fe0
2颅夺、上傳本地源碼到遠(yuǎn)程倉庫
參考文檔https://blog.csdn.net/u010412719/article/details/72860193
常用git命令:https://coding.net/help/doc/git/push.html
1)shifangfangdeMacBook-Pro:~ shifangfang$ mkdir postman_test
shifangfangdeMacBook-Pro:~ shifangfang$ cd postman_test/
shifangfangdeMacBook-Pro:postman_test shifangfang$ git init
Initialized empty Git repository in /Users/shifangfang/postman_test/.git/
shifangfangdeMacBook-Pro:postman_test shifangfang$ git add ~/Desktop/pro_env_order.postman_collection.json
fatal: /Users/shifangfang/Desktop/pro_env_order.postman_collection.json: '/Users/shifangfang/Desktop/pro_env_order.postman_collection.json' is outside repository
shifangfangdeMacBook-Pro:gitdemo shifangfang$ cd ~/postman_test/
shifangfangdeMacBook-Pro:postman_test shifangfang$ ls
shifangfangdeMacBook-Pro:postman_test shifangfang$ cp ~/Desktop/pro_env_order.postman_collection.json ./
shifangfangdeMacBook-Pro:postman_test shifangfang$ ls
pro_env_order.postman_collection.json
shifangfangdeMacBook-Pro:postman_test shifangfang$ cp ~/Desktop/pro_env.postman_environment.json ./
shifangfangdeMacBook-Pro:postman_test shifangfang$ ls
pro_env.postman_environment.json pro_env_order.postman_collection.json
shifangfangdeMacBook-Pro:postman_test shifangfang$ git add pro_env_order.postman_collection.json
shifangfangdeMacBook-Pro:postman_test shifangfang$ git add pro_env.postman_environment.json
shifangfangdeMacBook-Pro:postman_test shifangfang$ git commit -m "postman_pro_order"
[master (root-commit) a5927a5] postman_pro_order
2 files changed, 5931 insertions(+)
create mode 100644 pro_env.postman_environment.json
create mode 100644 pro_env_order.postman_collection.json
shifangfangdeMacBook-Pro:postman_test shifangfang$ git remote add originhttps://github.com/herry-ff/postman_test.git
shifangfangdeMacBook-Pro:postman_test shifangfang$ git push -u origin master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 13.63 KiB | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote:? ? ? https://github.com/herry-ff/postman_test/pull/new/master
remote:
To https://github.com/herry-ff/postman_test.git
* [new branch]? ? ? master -> master
Branch master set up to track remote branch master from origin.
shifangfangdeMacBook-Pro:postman_test shifangfang$
3捷犹、安裝newman
第一步:安裝nodejs重贺,
參考文檔:https://www.cnblogs.com/shiyunfront/p/7337783.html
? ? ? 1)先安裝brew,
命令行輸入?/usr/bin/ruby?-e?"$(curl?-fsSL?https://raw.githubusercontent.com/Homebrew/install/master/install)" ? 回車(這里有提示目錄不存在暑脆,要?jiǎng)?chuàng)建需要按return鍵,如果用的windows鍵盤跛锌,就是回車鍵)
? ? ? 2)brew install node
第二步:在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運(yùn)行json腳本
參考文檔https://github.com/postmanlabs/newman#configuring-reporters
run 腳本路徑
-e 環(huán)境變量路徑
-g 全局變量路徑
--reporter-html-export?報(bào)告路徑及名稱
--export-globals?路徑 執(zhí)行完更新后的全局變量文件
--export-environment路徑 執(zhí)行完更新后的環(huán)境變量文件
比如:
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創(chuàng)建freestyle job
PS:shell命令---html報(bào)告名稱前最好加個(gè)編號(hào),不然多次最新會(huì)一直覆蓋看不到之前生成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脑豹、構(gòu)建
PS:執(zhí)行構(gòu)建任務(wù)發(fā)現(xiàn)報(bào)錯(cuò),報(bào)錯(cuò)信息
/Users/Shared/Jenkins/tmp/jenkins5552974125428727684.sh: line 2: newman: command not found
Build step 'Execute shell' marked build as failure
參考:https://github.com/postmanlabs/newman/issues/778
解決辦法:配置好newman環(huán)境變量
5郑藏、本地倉庫變更上傳到遠(yuǎn)程倉庫,使用idea工具