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

Chatops with Hubot

Chatops with Hubot

This talk was given at Velocity Amsterdam 2015

Lorna Mitchell

October 30, 2015
Tweet

More Decks by Lorna Mitchell

Other Decks in Technology

Transcript

  1. ChatOps Brings the automation into the conversation. Team is in

    channel; information needs to be there too
  2. Choose Your Bot • Lita (ruby) https://www.lita.io/ • Err (python)

    http://errbot.net/ • Hubot (coffeescript) https://hubot.github.com/
  3. Meet Hugh Hugh is a hubot. Here, I'm running: •

    IRC server: miniircd https://github.com/jrosdahl/miniircd • IRC client: irssi http://irssi.org/
  4. 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
  5. 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/
  6. Plugins Very easy scripting, make a scripts/*.coffee file and export

    a function: module.exports = (robot) -> # your code here
  7. Plugins Simple plugin: use cron to do a timed feature

    Also: happy hour, standup meetings
  8. 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
  9. 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')
  10. 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
  11. Webhooks Collate events from all tools into your chat rooms

    Alerts from: • monitoring/logs • commits • issues/pull requests • deploys
  12. 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)
  13. ChatOps in Teams Unsolicited advice from me: • Works for

    open source and commercial teams • Build on existing plugins • Don't take it too seriously
  14. 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