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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
【FinOps】データドリブンな意思決定を目指して
z63d
0
330
10年間のブログ発信を振り返って見えたWebアプリケーションエンジニアとしての軌跡
stefafafan
0
180
AWS Security Agent といっしょに脅威モデリングをやってみよう
amarelo_n24
1
210
フィジカル版Github Onshapeの紹介
shiba_8ro
0
320
新しいUbuntu/GNOMEが使いたいからXからWaylandへ移行頑張ってるの巻 2026-06-20
nobutomurata
0
160
秘密度ラベル初心者が第1歩でつまづかないための「設計・運用」ポイント
seafay
PRO
1
480
AI時代のコスト管理を考えよう〜明日から使える実践AWSノウハウ~
yoshimi0227
0
860
感情と身体を置き去りにしない、エンジニアの生きのこり方 ──いまから、ここから「自分の状態」を扱うという選択
saorimurooka
0
340
AIはどのように 組織のアジリティを変えるのか?
junki
4
1.4k
FPGAの開発コンペでZephyrを使ってみた
iotengineer22
0
200
AI-DLCを “そのまま導入しなかった”話 ~組織に合わせてアジャストした 私たちの実践共有~
hiroramos4
PRO
1
420
From Prompt Engineering to Loop Engineering
shibuiwilliam
1
200
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
260
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
Chasing Engaging Ingredients in Design
codingconduct
0
230
Being A Developer After 40
akosma
91
590k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Accessibility Awareness
sabderemane
1
140
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ؒ࿈ܞͬͱָͦ͏ͳؾ͕͠ ͯΔ