Slide 1

Slide 1 text

ChatOps with Hubot Lorna Mitchell, October 2015

Slide 2

Slide 2 text

Think of DevOps

Slide 3

Slide 3 text

This is ChatOps

Slide 4

Slide 4 text

ChatOps Puts the "S" in CAMS A Culture of Automation, Measurement and Sharing

Slide 5

Slide 5 text

ChatOps Brings the automation into the conversation. Team is in channel; information needs to be there too

Slide 6

Slide 6 text

Choose Your Bot • Lita (ruby) https://www.lita.io/ • Err (python) http://errbot.net/ • Hubot (coffeescript) https://hubot.github.com/

Slide 7

Slide 7 text

Hubot "Friendly chat robot from GitHub" • Shared plugins • Good community

Slide 8

Slide 8 text

Supported Channels • Slack • Campfire • Hipchat • IRC • Shell • ... pluggable adapters

Slide 9

Slide 9 text

Installation Very easy install via yeoman: https://hubot.github.com/docs/ Bonus blog post: http://lrnja.net/1KugmaC Then: ./bin/hubot

Slide 10

Slide 10 text

Meet Hugh Hugh is a hubot. Here, I'm running: • IRC server: miniircd https://github.com/jrosdahl/miniircd • IRC client: irssi http://irssi.org/

Slide 11

Slide 11 text

Simply Deployable Designed to run on Heroku, easy to run elsewhere • Get Heroku toolchain • heroku create • Set environment variables • Configure Procfile • git push heroku master

Slide 12

Slide 12 text

Many Plugins Search for "hubot [thing]" on https://www.npmjs.com/ Install and add to list in external-scripts.json Or add your own code to scripts/

Slide 13

Slide 13 text

Plugins Very easy scripting, make a scripts/*.coffee file and export a function: module.exports = (robot) -> # your code here

Slide 14

Slide 14 text

Plugins Simple plugin: use cron to do a timed feature Also: happy hour, standup meetings

Slide 15

Slide 15 text

Plugin Code ROOM = process.env.HUBOT_TIMESHEET_REMINDER_ROOM cronJob = require('cron').CronJob module.exports = (robot) -> doReminder = -> robot.messageRoom(ROOM, "This is a polite reminder. Fill in your timesheets for the week, please"); job = new cronJob("0 0 17 * * 5", doReminder, null, true) https://github.com/lornajane/hubot-timesheet-reminder

Slide 16

Slide 16 text

Managing Plugins

Slide 17

Slide 17 text

robot.respond rules = [ "1. A robot may not injure a human being or, through inaction, allow a hu "2. A robot must obey any orders given to it by human beings, except wher "3. A robot must protect its own existence as long as such protection doe ] module.exports = (robot) -> robot.respond /(what are )?the (three |3 )?(rules|laws)/i, (msg) -> text = msg.message.text msg.send rules.join('\n')

Slide 18

Slide 18 text

robot.hear quotes = [ "Life! Don't talk to me about life", "Life, loathe it or ignore it, you can't like it", "Life's bad enough as it is without wanting to invent any more of it", "Funny, how just when you think life can't possibly get any worse it sudd ] module.exports = (robot) -> robot.hear /(.*)(life)(.*)/i, (msg) -> msg.send msg.random quotes

Slide 19

Slide 19 text

Webhooks Collate events from all tools into your chat rooms Alerts from: • monitoring/logs • commits • issues/pull requests • deploys

Slide 20

Slide 20 text

Webhooks

Slide 21

Slide 21 text

Webhooks In Practice

Slide 22

Slide 22 text

Webhooks In Practice

Slide 23

Slide 23 text

Webhooks In Practice

Slide 24

Slide 24 text

Webhooks In Practice

Slide 25

Slide 25 text

Developing for Webhooks To test webhooks on a dev platform, try ngrok (https://ngrok.com/) Secure tunnel to a port on your machine, with: • ability to inspect traffic • option to replay (rather than having to retrigger)

Slide 26

Slide 26 text

API Calls Command your bot

Slide 27

Slide 27 text

Team Relations • Thanks plugin • Karma • Ship It • The Rules

Slide 28

Slide 28 text

ChatOps in Teams Unsolicited advice from me: • Works for open source and commercial teams • Build on existing plugins • Don't take it too seriously

Slide 29

Slide 29 text

ChatOps in Teams Unsolicited advice from me: • Works for open source and commercial teams • Build on existing plugins • Don't take it too seriously • Never ask permission

Slide 30

Slide 30 text

Thanks!