Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hubot事例
Search
ryonext
January 21, 2015
Technology
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Hubot事例
弊社のHubotとSlack連携の活用事例です。
ryonext
January 21, 2015
More Decks by ryonext
See All by ryonext
AWS Lambda の Ruby 対応
ryonext
0
270
TwitterのList編集しやすいやつ作った
ryonext
0
1.8k
validationについて
ryonext
1
850
AWS Lambda と API GatewayでRails使わずに済んだ話
ryonext
8
4.4k
capistrano-bundle_rsync使ったらオートスケールが高速化した話
ryonext
8
2.6k
PumaとUnicornで最近自分が理解したこと
ryonext
13
9.6k
Redisでバッチ処理を冗長化しつつ排他制御
ryonext
0
2.1k
CircleCIとwercker
ryonext
3
1.3k
rubykaigi 3day interactive white board
ryonext
2
400
Other Decks in Technology
See All in Technology
はじめてのWDM
miyukichi_ospf
1
120
“全部コピーしない”ファイルデータの活用 : — FSx for ONTAP × S3 Tables × Icebergで作るメタデータカタログ
yoshiki0705
0
560
攻撃者がいなくてもAIエージェントはインシデントを起こす
nomizone
0
200
AIDLC_ヤフーショッピングの取り組み
lycorptech_jp
PRO
0
570
Zoom2Youtube.Claude
kawaguti
PRO
3
460
地域 SRE コミュニティ最前線 / SRE NEXT 2026 Discussion Night Track C
muziyoshiz
0
160
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
8.4k
AI駆動開発におけるQAエンジニアの役割事例 〜AI駆動開発の現場から〜
kobayashiyorimitsu
0
400
そのタスクオンスケですか?
poropinai1966
0
140
Text-to-SQLをAgentCoreで実現し、生成されるSQLの精度を定量的に評価する
yakumo
2
680
Kotlin 開発のツラミを爆破した話! / Explode the difficulty of Kotlin dev!
eller86
0
150
しぶいSRE: サーバから見えない障害にどう向き合うか。ラストワンマイルのデバッグ実践 / Shibui SRE
kanny
12
5.1k
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.8k
The Invisible Side of Design
smashingmag
301
52k
Producing Creativity
orderedlist
PRO
348
40k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.7k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Building an army of robots
kneath
306
46k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Transcript
ฐࣾͷHubotࣄྫ
ࣗݾհ Twitter ID: ryonext Unicon ͱ͍͏ձࣾͰRailsॻ͍ͯ·͢ɻ PS4ങ͍·ͨ͠ 2014ՆΠϕΫϦΞ·Ͱ͙ͬͨΒ͍ͷఏಜͩ ͚Ͳ͖ͬͺΓΊͨͷͰ؋͜ΕΞχϝݟͯ·ͤΜ
Hubotࣄྫ
develop ͔Β master ͷ pull request Λ࡞Δ ඞཁͳαʔϏε Circle CI
ͪΖΜ J但 Ͱ͍͚Δ masterʹϚʔδ͞ΕͨΒ ͦͷ··ຊ൪σϓϩ Π·ͰΔΑ͏ʹͯ͠Δલఏ
σϓϩΠ͍ͨ͠ͱ͖ʹ develop => master ͷ pull req Λ࡞Δͱ͍͏ϧʔνϯϫʔΫ͕ͳ͘ͳ Γੜ࢈ੑͷ্ʹͭͳ͕Δ
pull req ҰཡΛग़͢ hubot show org-pulls ͱ͍͏ίϚϯυ ͜ΕΛͬͯΔ hubot-scripts/github-pulls.coffee at
master · github/hubot-scripts https:/ /github.com/github/ hubot-scripts/blob/master/src/scripts/github- pulls.coffee ࠓ্͕͍ͬͯΔpull requestΛશ෦ग़͢ ޙड़ͷ cron ͱΈ߹Θͤͯ͏͖
ΤϯδχΞ͕ࣗൃతʹpull requestΛݟʹߦ͘ඞཁ͕ͳ͘ͳΓɺ͔͠ཹ͍ͯ͠Δpull request Λݟ͚ͭΔ͜ͱՄೳʹͳΓੜ࢈ੑͷ্ʹͭͳ͕Δ
cron ఆظతʹಛఆͷൃݴΛͤ͞Δ ͜ΕͬͯΔ ncb000gt/node-cron https:/ / github.com/ncb000gt/node-cron ձٞͷϦϚΠϯυΛͨ͠Γɺલड़ͷpull req ҰཡΛݺͼग़ͨ͠Γɺ͍ํࣗ༝ࣗࡏ
ఆظతʹඞཁͳॲཧΛࣗಈ࣮ߦͯ͘͠ΕΔ͜ͱʹΑΓੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ1 pull requestͷ௨ ຖܾ·ͬͨ࣌ؒʹͳͬͨΒ hubot show org-pulls Λ࣮ߦ͠ɺpull request ҰཡΛ
ग़͢ ຖܾ·ͬͨ࣌ؒʹ͍ͬͯΔpull requestΛදࣔ͢Δ͜ͱʹΑΓɺϨϏϡʔ͕ଅਐ͞Εੜ࢈ੑͷ ্ʹͭͳ͕Δ
cronࣄྫ2 ேձ&༦ձ + Google Hangouts URLͷ௨ ܾ·ͬͨ࣌ؒʹேձ/༦ձͷ௨ͱɺϦϞʔτ ۈऀ༻ʹGoogle HangoutsͷURLΛߘ
͢Δ͜ͱʹΑΓεϜʔζͳձٞͷ։͕࢝Ͱ͖Δ
ேձʗ༦ձʹΕΔ͜ͱ͕ͳ͘ͳΓɺHangoutsͷURLΛ୳͢ख͕ؒল͚ͯੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ 3 9࣌ʹͳͬͨΒࠓ1ؤுΔܾҙΛࣔ͢ը૾ ΛషΔ ࠓҰؤுΕͦ͏ͳը૾ΛݟΔ͜ͱʹΑΓੜ࢈ੑ্ʹͭͳ͕Δ ͨͩ͠ϑϨοΫε͔ͩΒ9͔࣌Βಇ͍͍ͯΔਓ͕গͳ͍
cronࣄྫ3 ͓ͭͷ࣌ؒΛ௨͢Δ 15࣌Λ௨͢Δ͜ͱͰɺΤϯδχΞʹิڅΛଅ͠ɺੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ4 ਐḿͷ֬ೝ ϥϯνΛ৯ͯɺ͓ͭΛ৯ͯɺੜ࢈ੑ͕ۃݶ·Ͱߴ·ͬͨΤϯδχΞ͕ͦͷྗΛ༨͢͜ͱແ͘ൃش͠ ͨ͋ͨΓͰͦͷՌΛ֬ೝ͢Δ͜ͱͰϞνϕʔγϣϯ͕Ξοϓ͠ɺੜ࢈ੑͷ্ʹͭͳ͕Δ
cronࣄྫ5 ՖۚΛ௨͢Δ ͨ͠ͳΊΔ ༵ۚͷָ͠͞Λ௨͢ΔͱͱʹɺؾΛҾ͖కΊΔ͜ͱ͕Ͱ͖ੜ࢈ੑͷ্ʹͭͳ͕Δ
͔͜͜Βৄࡉฤ
શମߏ GitHubͷνʔϜΞΧϯτ͕2ͭ͋ΔͨΊɺऔ ಘ༻ͷhubot͕2ମ Cron༻ͷhubot͕1ମ mention༻ʹslackbotΛ׆༻
શମߏɺϦϙδτϦͱ ಈ࡞ڥฤ GitHubcron༻ͷhubotͰ1ϦϙδτϦɺͦ ΕҎ֎ͷhubotͰ1ϦϙδτϦ Herokuʹcron༻Ͱ1, ͦΕҎ֎༻Ͱ2ͭͬ ͯɺڥมͰΞΫηε͢ΔGitHubΛ͍ ͚͍ͯΔ
CronҎ֎༻ͷڥม
Cron༻ͷڥม
develop͔Βmasterͷ pull req ͜Μͳײ͡ͷίʔυ 18 module.exports = (robot) -> 19
github = require("githubot")(robot) 20 robot.respond /deploy ?(.+)/i, (msg) -> 21 repo = msg.match[1] 22 url_api_base = "https://api.github.com" 23 data = { 24 "title": "deploy", 25 "head": "develop", 26 "base": "master" 27 } 28 ghOrg = process.env.HUBOT_GITHUB_ORG 29 url = "#{url_api_base}/repos/#{ghOrg}/#{repo}/pulls" 30 github.post url, data, (response) -> 31 msg.send "ຊ൪ʹσϓϩΠ͢ΔϓϧϦΫΤετΛ࡞ͨ͠Αʂ֬ೝͯ͠Ϛʔδͯ͠Ͷʂ" 32 msg.send response.html_url https:/ /gist.github.com/ryonext/2906f7bd9c865c2d8f1b
pull reqҰཡΛग़͢ https:/ /github.com/github/hubot- scripts/blob/master/src/scripts/ github-pulls.coffee
cron Hubotͷslack adapter Ͱ ఆظతʹൃݴ ͤ͞Δ͜ͱͰ͖Δ͕ɺbotͷൃݴʹରͯ͠bot ʹԠͤ͞Δ͜ͱͰ͖ͳ͍ʢॏཁʣ ͕ͨͬͯ͠ɺxmppΛͬͯൃݴͤ͞Δඞཁ͕ ͋Δ
xmpp xmpp Λ͏߹ɺhubot ͷslack adapterΛ͏߹ͱҧ͍ɺxmppͰૢ࡞͢ ΔͨΊͷslack accountΛ࡞͓ͬͯ͘ඞཁ͕ ͋Δ
Πϝʔδ slack adapter xmpp adapter slack account
xmpp͏߹ͷઃఆ ʢslackଆʣ
hubot x xmpp x slack
None
None
xmpp͏߹ͷઃఆ ʢhubotଆʣ ‘hubot-slack’ͷΘΓʹ’hubot-xmpp’Λ npm install͢Δ heroku ʹ্͛Δ߹ɺίϚϯυΛ `web: bin/hubot --adapter
xmpp -n {bot໊}` ʹ͢Δ
xmppิ xmppͰൃݴͨ͠༰mentionʹͳΒͳ͍ ʢॏཁʣ ͔ͤͬ͘ϨϏϡʔ௨ͯ͠ؾ͔ͮΕͳ͍ slackbot࿈ܞͤ͞ΔɻcronͰͷൃݴʹର͠ ͯslackbotʹԠͤ͞Δ
͜͏ͬͯ
͜͏ͳΔͷͰpush௨͕ དྷΔ
͓͠·͍ ࣭͋Εؾܰʹฉ͍͍ͯͩ͘͞ɻ HipChatͩͱbotؒ࿈ܞͬͱָͦ͏ͳؾ͕͠ ͯΔ