1 | $ wsk package update myGit -p repository icnbrave/garbage-test-app -p accessToken <GITHUB_ACCESSTOKEN> -p username <GITHUB_USERNAME> |
1 | $ wsk trigger create gitTrigger --feed myGit/webhook -p events push |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ... "commits": [ { "id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", "tree_id": "f9d2a07e9488b91af2641b26b9407fe22a451433", "distinct": true, "message": "Update README.md", "timestamp": "2015-05-05T19:40:15-04:00", "url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", "author": { "name": "baxterthehacker", "email": "baxterthehacker@users.noreply.github.com", "username": "baxterthehacker" }, "committer": { "name": "baxterthehacker", "email": "baxterthehacker@users.noreply.github.com", "username": "baxterthehacker" }, "added": [ ], "removed": [ ], "modified": [ "README.md" ] } ], ... |
1 | $ wsk action create getPushPayloadAction getPushPayload.js |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | function main(params){ var testAppUrl = "https://garbagetestapp.mybluemix.net/"; var head_commit = params["head_commit"] || ""; var files = []; if(head_commit != ""){ files=files.concat(head_commit["added"]); files=files.concat(head_commit["modified"]); } console.log("files: ", files); // files map to test app link var urls=[]; for(var i=0,len=files.length; i<len; i++){ urls.push(testAppUrl + files); } return {payload: urls.join(",")}; } |
1 | $ wsk rule create git2slackRule gitTrigger getPushPayloadAction |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |