{"id":7812,"date":"2015-06-18T18:10:44","date_gmt":"2015-06-18T09:10:44","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=7812"},"modified":"2018-11-14T16:33:47","modified_gmt":"2018-11-14T07:33:47","slug":"slackxhubot%e3%81%a7chatops%e3%82%92%e3%81%af%e3%81%98%e3%82%81%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2015\/06\/18\/slackxhubot%e3%81%a7chatops%e3%82%92%e3%81%af%e3%81%98%e3%82%81%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"Slack\u00d7Hubot\u3067ChatOps\u3092\u306f\u3058\u3081\u3066\u307f\u305f"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u5c0f\u91ce\u5bfa\u3067\u3059\u3002<\/p>\n<p>\u79c1\u304c\u6240\u5c5e\u3057\u3066\u3044\u308b\u30b0\u30eb\u30fc\u30d7\u3067\u306f\u3001\u958b\u767a\u7528\u306e\u30c1\u30e3\u30c3\u30c8\u30c4\u30fc\u30eb\u306bSlack\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\nSlack\u306f\u591a\u304f\u306e\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u9023\u643a\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u9b45\u529b\u7684\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u524d\u304b\u3089\u6c17\u306b\u306a\u3063\u3066\u3044\u305f\u3001ChatOps\u3092\u306f\u3058\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>ChatOps\u306f\u7c21\u5358\u306b\u8a00\u3046\u3068\u30c1\u30e3\u30c3\u30c8\u4e0a\u306bbot\u3092\u7528\u610f\u3057\u3066\u3001\u305d\u306ebot\u306b\u30c1\u30e3\u30c3\u30c8\u3067\u547c\u3073\u304b\u3051\u308b\u3068bot\u304c\u3044\u308d\u3044\u308d\u3084\u3063\u3066\u304f\u308c\u308b\u3068\u3044\u3046\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001Slack\u3068Hubot\u3001\u305d\u3057\u3066GitLab\u3092\u4f7f\u3063\u3066ChatOps\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/Untitled1.png\" rel=\"facebox\" rel=\"attachment wp-att-7816\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/Untitled1.png\" alt=\"ChatOps\" width=\"682\" height=\"101\" class=\"aligncenter size-full wp-image-7816\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/Untitled1.png 682w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/Untitled1-300x44.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><\/p>\n<p>\u203bSlack\u3068Hubot\u306e\u9023\u643a\u306b\u3064\u3044\u3066\u306f\u5272\u611b\u3057\u307e\u3059\u3002(\u307b\u3068\u3093\u3069\u8a2d\u5b9a\u3044\u3089\u306a\u3044\u3067\u3059)<\/p>\n<p>\u5b9f\u88c5\u3059\u308b\u306e\u306f\u6b21\u306e\uff12\u3064\u306e\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u30d6\u30e9\u30f3\u30c1\u306e\u4f5c\u6210<\/li>\n<li>\u30de\u30fc\u30b8\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u4f5c\u6210<\/li>\n<\/ul>\n<p>GitLab\u306fAPI\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u306e\u3067\u3001Hubot\u3067GitLabAPI\u3092\u4f7f\u3063\u3066\u5b9f\u73fe\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>Hubot\u306fNode.js\u3067\u4f5c\u3089\u308c\u3066\u3044\u308b\u306e\u3067\u3001npm\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u4f7f\u3048\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001GitLabAPI\u3092Node.js\u3067\u4f7f\u3048\u308b<a href=\"https:\/\/www.npmjs.com\/package\/gitlab\" target=\"_blank\">gitlab\u30e2\u30b8\u30e5\u30fc\u30eb<\/a>\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \" >\r\n# Connection\r\ngitlab = (require 'gitlab')\r\n  url:   'http:\/\/example.com'\r\n  token: 'abcdefghij123456'\r\n\r\nmodule.exports = (robot) -&gt;\r\n\r\n  # Listing users\r\n  robot.respond \/gitlab users all\/i, (msg) -&gt;\r\n    gitlab.users.all (users) -&gt;\r\n      msg.send \"##{user.id}: #{user.email}, #{user.name}, #{user.created_at}\" for user in users\r\n<\/pre>\n<p>\u3053\u308c\u3067GitLab\u306e\u30e6\u30fc\u30b6\u30fc\u4e00\u89a7\u3092\u898b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff01<br \/>\n<a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img1.png\" rel=\"facebox\" rel=\"attachment wp-att-7818\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img1.png\" alt=\"img1\" width=\"639\" height=\"132\" class=\"aligncenter size-full wp-image-7818\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img1.png 639w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img1-300x62.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<p>\u3053\u306e\u6642\u306f\u3001Hubot\u3067GitLabAPI\u4f7f\u3046\u306e\u306a\u3093\u3066\u697d\u52dd\u3060\u306a\u3068\u304b\u601d\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3002\u3002<\/p>\n<p>\u3088\u3057\u3001\u30d6\u30e9\u30f3\u30c1\u4f5c\u6210\u3068\u30de\u30fc\u30b8\u30ea\u30af\u30a8\u30b9\u30c8\u3082\u540c\u3058\u3088\u3046\u306b\u5b9f\u88c5\u3057\u3088\u3046\uff01<\/p>\n<pre class=\"lang:default decode:true \" >\r\n# Branch\u306e\u4f5c\u6210\r\n  robot.respond \/gitlab create branch (.*) from (.*) on (.*)$\/i, (msg) -&gt;\r\n    branch_name = msg.match[1].trim()\r\n    ref = msg.match[2].trim()\r\n    project_id = msg.match[3].trim()\r\n    params = {projectId: project_id, branch_name: branch_name, ref: ref}\r\n    msg.send \"branch \u300c#{branch_name}\u300d \u3092\u4f5c\u3063\u3066\u3044\u307e\u3059\u3002\"\r\n    gitlab.projects.repository.createBranch params, (branch) -&gt;\r\n      if branch?\r\n        msg.send \"\u300c#{branch.name}\u300d \u304c\u4f5c\u308c\u3089\u308c\u307e\u3057\u305f\u3002\"\r\n      else\r\n        msg.send \"\u300c#{branch_name}\u300d \u3092\u4f5c\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\"\r\n\r\n# MergeRequest\u306e\u4f5c\u6210\r\nrobot.respond \/gitlab merge_request (.*) to (.*) on (.*) who (.*) title (.*)$\/i, (msg) -&gt;\r\n  source_branch = msg.match[1].trim()\r\n  target_branch = msg.match[2].trim()\r\n  project_id = msg.match[3].trim()\r\n  assignee_id = msg.match[4].trim()\r\n  title = msg.match[5].trim()\r\n  msg.send \"merge request \u300c#{title}\u300d\u3092\u4f5c\u3063\u3066\u3044\u307e\u3059\u3002\"\r\n  gitlab.projects.merge_requests.add project_id, source_branch, target_branch, assignee_id, title, (merge_request) -&gt;\r\n    if merge_request?\r\n      msg.send \"\u300c#{merge_request.title}\u300d \u304c\u4f5c\u308c\u3089\u308c\u307e\u3057\u305f\u3002\"\r\n    else\r\n      msg.send \"\u300c#{title}\u300d \u3092\u4f5c\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\"\r\n<\/pre>\n<p>\u5b9f\u88c5\u3057\u3066\u307f\u3066\u6c17\u3065\u304d\u307e\u3057\u305f\u3002\u3042\u308c\u3001\u30b3\u30de\u30f3\u30c9\u304c\u3081\u3063\u3061\u3083\u9577\u304f\u306a\u3063\u3066\u308b\uff1f<\/p>\n<pre class=\"lang:default decode:true \" >\r\n#\u30d6\u30e9\u30f3\u30c1\u4f5c\u6210\r\nmybot gitlab create branch issue-12345 from develop on 1\r\nmybot gitlab merge_request [\u65b0\u3057\u3044\u30d6\u30e9\u30f3\u30c1] from [\u5143\u30d6\u30e9\u30f3\u30c1] on [\u30d7\u30ed\u30b8\u30a7\u30af\u30c8ID]\r\n\r\n#\u30de\u30fc\u30b8\u30ea\u30af\u30a8\u30b9\u30c8\r\nmybot gitlab merge_request issue-12345 to develop on 3 who 1 title \u30d0\u30b0\u306e\u4fee\u6b63\r\nmybot gitlab merge_request [\u30bd\u30fc\u30b9\u30d6\u30e9\u30f3\u30c1] to [\u30bf\u30fc\u30b2\u30c3\u30c8\u30d6\u30e9\u30f3\u30c1] on [\u30d7\u30ed\u30b8\u30a7\u30af\u30c8ID] who [\u30a2\u30b5\u30a4\u30f3ID] title [\u30bf\u30a4\u30c8\u30eb]\r\n<\/pre>\n<p>\u306a\u3001\u9577\u3044\u3002\u3002\u3002GitLab\u4e0a\u3067\u64cd\u4f5c\u3057\u305f\u307b\u3046\u304c(ry<br \/>\n\u3057\u304b\u3082\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8ID\u3068\u304b\u30a2\u30b5\u30a4\u30f3ID\u3068\u304b\u6df7\u3056\u3063\u3061\u3083\u3063\u3066\u307e\u3059\u3002\u3002\u3002<\/p>\n<p>\u3053\u306e\u307e\u307e\u3067\u306f\u8ab0\u3082\u4f7f\u3063\u3066\u304f\u308c\u306a\u3044\u306e\u3067\u3001\u6b21\u306e\u3088\u3046\u306a\u65b9\u91dd\u3092\u6c7a\u3081\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u30d6\u30e9\u30f3\u30c1\u4f5c\u6210\u6642\u306e \u5143\u30d6\u30e9\u30f3\u30c1 \u3092 \u30c7\u30d5\u30a9\u30eb\u30c8\u30d6\u30e9\u30f3\u30c1 \u306b\u9650\u5b9a(\u81ea\u52d5)<\/li>\n<li>\u30de\u30fc\u30b8\u5148\u306e \u30bf\u30fc\u30b2\u30c3\u30c8\u30d6\u30e9\u30f3\u30c1 \u3092 \u30c7\u30d5\u30a9\u30eb\u30c8\u30d6\u30e9\u30f3\u30c1 \u306b\u9650\u5b9a(\u81ea\u52d5)<\/li>\n<li>GitLab\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092Slack\u306eChannel\u3068\u30d2\u30e2\u4ed8(\u5225\u9014\u767b\u9332)<\/li>\n<li>\u30a2\u30b5\u30a4\u30f3\u30e6\u30fc\u30b6\u30fc\u3092 Slack\u306e\u30e6\u30fc\u30b6\u30fc\u3067\u9078\u629e\u53ef\u80fd\u306b (\u5225\u9014\u767b\u9332)<\/li>\n<li>\u30b3\u30de\u30f3\u30c9\u81ea\u4f53\u3082\u77ed\u304f\uff01<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u3092\u3075\u307e\u3048\u305f\u7d50\u679c\u3001\u4f7f\u3063\u3066\u3082\u3044\u3044\u304b\u306a\u304f\u3089\u3044\u306e\u30ec\u30d9\u30eb\u306b\u77ed\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true \" >\r\n#\u30d6\u30e9\u30f3\u30c1\u4f5c\u6210\r\nmybot git BR issue-12345\r\nmybot git BR [\u30bd\u30fc\u30b9\u30d6\u30e9\u30f3\u30c1]\r\n\r\n#\u30de\u30fc\u30b8\u30ea\u30af\u30a8\u30b9\u30c8\r\nmybot git MR issue-12345 @onodera.shunya \u30d0\u30b0\u306e\u4fee\u6b63\r\nmybot git MR [\u30bd\u30fc\u30b9\u30d6\u30e9\u30f3\u30c1] @[Slack\u30e6\u30fc\u30b6\u30fc\u540d] [\u30bf\u30a4\u30c8\u30eb]\r\n\u203bSlack\u3067\u306f@\u3092\u5165\u529b\u3059\u308b\u3068\u30e6\u30fc\u30b6\u30fc\u9078\u629e\u88dc\u52a9\u304c\u4f7f\u3048\u307e\u3059\uff01\r\n<\/pre>\n<p><a href=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img2.png\" rel=\"facebox\" rel=\"attachment wp-att-7823\"><img loading=\"lazy\" src=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img2.png\" alt=\"img2\" width=\"639\" height=\"301\" class=\"aligncenter size-full wp-image-7823\" srcset=\"https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img2.png 639w, https:\/\/www.techscore.com\/blog\/wp\/wp-content\/uploads\/2015\/06\/img2-300x141.png 300w\" sizes=\"(max-width: 639px) 100vw, 639px\" \/><\/a><\/p>\n<p>Slack\u306e\u60c5\u5831\u3068GitLab\u306e\u60c5\u5831\u306e\u767b\u9332\u306b\u306f\u3001<a href=\"http:\/\/expressjs.com\/ja\/\" target=\"_blank\">express<\/a>\u3068\u3044\u3046Node.js\u306eWeb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067Web\u30d5\u30a9\u30fc\u30e0\u3092\u4f5c\u308a\u3001Redis\u306b\u4fdd\u5b58\u3068\u3044\u3046\u65b9\u6cd5\u3067\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002\u3053\u3053\u3067\u767b\u9332\u3059\u308b\u60c5\u5831\u306b\u306fGitLab\u306e\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u30c8\u30fc\u30af\u30f3\u3082\u542b\u307e\u308c\u308b\u306e\u3067\u3001\u30c1\u30e3\u30c3\u30c8\u4e0a\u304b\u3089\u306e\u767b\u9332\u3092\u907f\u3051\u308b\u610f\u5473\u3082\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001GitLab\u306e\u64cd\u4f5c\u3092ChatOps\u3067\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u5f15\u304d\u7d9a\u304dbot\u3092\u80b2\u3066\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001\u5c0f\u91ce\u5bfa\u3067\u3059\u3002<\/p>\n<p>\u79c1\u304c\u6240\u5c5e\u3057\u3066\u3044\u308b\u30b0\u30eb\u30fc\u30d7\u3067\u306f\u3001\u958b\u767a\u7528\u306e\u30c1\u30e3\u30c3\u30c8\u30c4\u30fc\u30eb\u306bSlack\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\nSlack\u306f\u591a\u304f\u306e\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u9023\u643a\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b\u9b45\u529b\u7684\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2015\/06\/18\/slackxhubot%e3%81%a7chatops%e3%82%92%e3%81%af%e3%81%98%e3%82%81%e3%81%a6%e3%81%bf%e3%81%9f\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":41,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[203,46],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/7812"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=7812"}],"version-history":[{"count":12,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/7812\/revisions"}],"predecessor-version":[{"id":7827,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/7812\/revisions\/7827"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=7812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=7812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=7812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}