Slide 1

Slide 1 text

Hubot ChatOps 『FED Party 14』 持續進展的專案!Continuous Integration

Slide 2

Slide 2 text

Win Wu Frontend Engineer Koa (Node) Laravel (PHP) HTML / JavaScript / CSS (…) Love coding / travel / enjoy life $ whoami Photo By Arvin

Slide 3

Slide 3 text

ಠ‿ಠ Hubot ? Node ? Question! Jenkins Slack Hipchat

Slide 4

Slide 4 text

•  Hubot is a Chat bot.

Slide 5

Slide 5 text

hubot.github.com

Slide 6

Slide 6 text

•  Created By •  Use •  Engine is •  Brain is

Slide 7

Slide 7 text

http://www.youtube.com/watch?v=NST3u-GjjFw ChatOps at GitHub - Jesse Newland https://speakerdeck.com/jnewland/chatops-at-github

Slide 8

Slide 8 text

http://www.youtube.com/watch?v=-LxavzqLHj8 MountainWest RubyConf 2013 ChatOps at GitHub by Jesse Newland

Slide 9

Slide 9 text

•  Search images. •  translating languages. •  Search Youtube. •  CI (Jenkins) Notification •  Some Easy Cron Job •  The real fun happens when you add your own scripts. •  ⇔ग़⚧߄֥4DSJQU∣ἐ὜൞۷ݺທb What can Hubot Do?

Slide 10

Slide 10 text

Who Use Hubot? etc….

Slide 11

Slide 11 text

Chat room for Your Hubot •  Hubot 提供 3 種類型的 Adapter – Official Adapter •  Shell, i.e. for use with development •  Campfire – Third Party Adapter (next page) – Write Your Own Adapter

Slide 12

Slide 12 text

•  Third Party Adapter Gitter IRC

Slide 13

Slide 13 text

ಠ_ಠ Then? How To Start ?

Slide 14

Slide 14 text

1. Environment (1) You need a server. (or your local XD) ( 網路上⼤大部分的⽂文章會⽤用如何在 Deploy 你的 Hubot )

Slide 15

Slide 15 text

1. Environment (2) Refercnce: dockerでhubot + slack

Slide 16

Slide 16 text

2. Install Your Hubot •  ˸ɨ݊̀ცۜ̀ࠅӉ᜷ –  Install Node.js (nvm suggest). –  Install npm / CoffeeScript –  Install Redis –  Install Hubot –  Configure Adapter –  Configure for your Hubot

Slide 17

Slide 17 text

Install Example: (On the Ubuntu Server) $ sudo apt-get install nodejs $ sudo apt-get install npm $ sudo apt-get install build-essential libssl-dev $ sudo apt-get install libexpat1-dev $ sudo apt-get install libicu-dev $ sudo apt-get install nodejs-legacy $ npm install --global coffee-script [email protected] $ sudo npm install -g coffee-script $ hubot –create $ cd YOUR_FOLDER $ hubot --create

Slide 18

Slide 18 text

mybot folder root@demo-server:/home/dev/mybot# ll ./ ../ bin/ external-scripts.json .git/ .gitignore hubot-scripts.json node_modules/ package.json Procfile README.md scripts/

Slide 19

Slide 19 text

Install Adapter $ npm install --save hubot-hipchat hubot-slack hubot-gitter2 …

Slide 20

Slide 20 text

Setting Adapter •  Hipchat •  Slack

Slide 21

Slide 21 text

Example: Adapter 是 Hipchat •  為 Hubot 申請⼀一個 account •  取得該 account 的 TOKEN, JID ,寫⼊入設 定到 bin/hubot。

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

vi bin/hubot - ex: Hipchat

Slide 25

Slide 25 text

vi Procfile 在 Procfile 增加這⼀一⾏行: web: bin/hubot --adapter hipchat

Slide 26

Slide 26 text

Example: Adapter 是 Slack

Slide 27

Slide 27 text

增加 hubot 的 service https://YOUR_DOMAIN.slack.com/services

Slide 28

Slide 28 text

增加 hubot 的 service

Slide 29

Slide 29 text

configure

Slide 30

Slide 30 text

configure

Slide 31

Slide 31 text

vi bin/hubot - ex: slack

Slide 32

Slide 32 text

vi Procfile web: bin/hubot --adapter slack

Slide 33

Slide 33 text

3. Boot your Hubot (root@demo-server:/home/dev/mybot# bin/hubot -a hipchat) root@demo-server:/home/dev/mybot# bin/hubot -a YOUR_ADAPTER_NAME [Fri Nov 07 2014 00:43:52 GMT-0500 (EST)] INFO Connecting HipChat adapter... createCredentials() is deprecated, use tls.createSecureContext instead [Fri Nov 07 2014 00:43:57 GMT-0500 (EST)] INFO Connected to hipchat.com as @hubot [Fri Nov 07 2014 00:43:57 GMT-0500 (EST)] INFO Data for hubot brain retrieved from Redis [Fri Nov 07 2014 00:43:59 GMT-0500 (EST)] INFO Joining [email protected] 不同的 Adapter 吐出來的訊息不同。

Slide 34

Slide 34 text

3. Boot your Hubot

Slide 35

Slide 35 text

Boot your Hubot (ex:hipchat)

Slide 36

Slide 36 text

Boot your Hubot (ex:Slack) •  Hubot 可以佔⽤用 slackbot 這個 username

Slide 37

Slide 37 text

3. Test you Hubot @slackbot ping

Slide 38

Slide 38 text

3. Test you Hubot @slackbot image 正妹

Slide 39

Slide 39 text

3. Test you Hubot @slackbot youtube 我可能不會愛你

Slide 40

Slide 40 text

3. Test you Hubot

Slide 41

Slide 41 text

3. Test you Hubot @slackbot time

Slide 42

Slide 42 text

Install Other Hubot Scripts •  https://github.com/hubot-scripts/

Slide 43

Slide 43 text

τༀ˙ج •  τༀՉ˼ٙIVCPUTDSJQUӉ᜷ɽΝʃମf •  ˸τༀIVCPUUIBOLZPVމԷ $ npm install hubot-thank-you --save 將 hubot-thank-you 加到 external-scripts.json 的 array 裡⾯面 : ["hubot-thank-you"] 加完之後,記得重啟 hubot。 1 3 2

Slide 44

Slide 44 text

Hubot-Thank-You https://github.com/hubot-scripts/hubot-thank-you

Slide 45

Slide 45 text

hubot-thesimpsons https://github.com/hubot-scripts/hubot-thesimpsons

Slide 46

Slide 46 text

hubot-cron https://www.npmjs.org/package/hubot-cron

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

hubot-fliptable https://github.com/hubot-scripts/hubot-fliptable

Slide 49

Slide 49 text

Vi external-scripts.json root@demo-server:/home/dev/mybot# vi external-scripts.json ["hubot-thank-you", "hubot-standup-alarm", "hubot-plusplus", "hubot- thesimpsons", "hubot-cron”]

Slide 50

Slide 50 text

)VCPUٙɓԬᏐ͜˙ό

Slide 51

Slide 51 text

•  寫好⼀一些⾃自動化流程的 shell 或是有 API 可以 Call –  主要⽤用於 notification,Example : •  主機狀況監控 •  Error reporting •  每⽇日推播⼀一圖或⼀一句⾦金⽟玉良⾔言 •  開會通知 •  etc…. •  寫⾃自⼰己的 Hubot-script (hubot 指令) –  ⽤用於 Deploy Project 到不同的開發環境 (development/ staging/production... )

Slide 52

Slide 52 text

Jenkins-job.coffee •  新增 jenkins-job.coffee 檔案在 scripts 資料夾

Slide 53

Slide 53 text

Chat Room Jenkins Job @slackbot jenkins-job JENKINS_JOB_NAME Response Jenkins Job Result

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

這串訊息跟 hubot 本⾝身沒有關係,但如果有需要的話必須設定額外設定。 以 slack 為例就是必須增加 servicec 項⺫⽬目, 然後 Jenkins 必須安裝 slack 的 notification 的外掛。

Slide 57

Slide 57 text

Deploy Every Where > <

Slide 58

Slide 58 text

Reference •  https://github.com/github/janky •  https://github.com/atmos/heaven/blob/master/doc/overview.md •  https://github.com/phoorichet/GraphMe •  https://github.com/hubot-scripts/hubot-pager-me •  http://www.larrycaiyu.com/blog/2014/01/21/ hubot_jenkins_notification/ •  Automate Your Development Activities with Hubot (y) •  Beginning a journey to chatops with Hubot Posted by Ryan Tomlinson (y)

Slide 59

Slide 59 text

'SPOU&OE]]#BDLFOE&OHJOFFS 8F/FFE:PV

Slide 60

Slide 60 text

Thank You! (ಠ‿ಠ) ߰Ϟ፹Ⴌא΂Оࠠࠅ༟ৃ፲ဍdሗFNBJM XJOXVZPVNFCDPN หሗܸ઺dᑽᑽ