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 with Hubot
    Lorna Mitchell, October 2015

    View Slide

  2. Think of DevOps

    View Slide

  3. This is ChatOps

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  11. 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

    View Slide

  12. 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/

    View Slide

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

    View Slide

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

    View Slide

  15. 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

    View Slide

  16. Managing Plugins

    View Slide

  17. 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')

    View Slide

  18. 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

    View Slide

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

    View Slide

  20. Webhooks

    View Slide

  21. Webhooks In Practice

    View Slide

  22. Webhooks In Practice

    View Slide

  23. Webhooks In Practice

    View Slide

  24. Webhooks In Practice

    View Slide

  25. 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)

    View Slide

  26. API Calls
    Command your bot

    View Slide

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

    View Slide

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

    View Slide

  29. 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

    View Slide

  30. Thanks!

    View Slide