Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ChatOps-Hubot

winwu
November 27, 2014

 ChatOps-Hubot

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

winwu

November 27, 2014
Tweet

More Decks by winwu

Other Decks in Programming

Transcript

  1. Win Wu Frontend Engineer Koa (Node) Laravel (PHP) HTML /

    JavaScript / CSS (…) Love coding / travel / enjoy life $ whoami Photo By Arvin
  2. •  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?
  3. 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
  4. 1. Environment (1) You need a server. (or your local

    XD) ( 網路上⼤大部分的⽂文章會⽤用如何在 Deploy 你的 Hubot )
  5. 2. Install Your Hubot •  ˸ɨ݊̀ცۜ̀ࠅӉ᜷ –  Install Node.js (nvm

    suggest). –  Install npm / CoffeeScript –  Install Redis –  Install Hubot –  Configure Adapter –  Configure for your Hubot
  6. 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 <mybot> $ cd YOUR_FOLDER $ hubot --create <mybot>
  7. 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/
  8. Example: Adapter 是 Hipchat •  為 Hubot 申請⼀一個 account • 

    取得該 account 的 TOKEN, JID ,寫⼊入設 定到 bin/hubot。
  9. 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 吐出來的訊息不同。
  10. τༀ˙ج •  τༀՉ˼ٙIVCPUTDSJQUӉ᜷ɽΝʃମf •  ˸τༀIVCPUUIBOLZPVމԷ $ npm install hubot-thank-you --save

    將 hubot-thank-you 加到 external-scripts.json 的 array 裡⾯面 : ["hubot-thank-you"] 加完之後,記得重啟 hubot。 1 3 2
  11. •  寫好⼀一些⾃自動化流程的 shell 或是有 API 可以 Call –  主要⽤用於 notification,Example

    : •  主機狀況監控 •  Error reporting •  每⽇日推播⼀一圖或⼀一句⾦金⽟玉良⾔言 •  開會通知 •  etc…. •  寫⾃自⼰己的 Hubot-script (hubot 指令) –  ⽤用於 Deploy Project 到不同的開發環境 (development/ staging/production... )
  12. 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)