Git Slack Integration
Course Overview
In this course, you will learn:
What is ChatOps
Key Players - Chat Client and Chat Bot
Role of ChatOps in AgileDevOps
Integration Capabilities
Integration of Chat Client Slack, Chatbot Jirio with GitHub
What is ChatOps?
ChatOps is a digital-age manifestation of Conversation-driven Collaboration, that
allows people to:
Work together
Work better
Simplify daily operations
Team Collaboration and conversations happen in Chat clients and ChatOps is often
aided by a Conversational AI-based Bot that can trigger tasks and provide information
for simple English commands.
How ChatOps Works?
ChatOps connects people, bots, and tools in an automated and transparent workflow,
making information readily available from a chat window.
ChatOps is as much a cultural change as a technology change. It removes the
disconnect between tasks and the conversations, Bringing more Transparency.
Why ChatOps?
ChatOps functionalities usually have bots that can connect to several apps. Bots are
capable of performing variety of tasks inside the chat, like:
Code deployment
Software test kick off
Issue logging and tracking
Server reboots
As an added bonus, chat application contains clear record of all discussions and scripts
executed—something very handy for*** root cause analysis and troubleshooting***.
Benefits of ChatOps
Rolling out ChatOps in an organization has the potential to provide a large number of
benefits like:
Increased collaboration
Increased Automation
Faster Incident Resolution
Knowledge Sharing
Higher Visibility
Cross Learning
Building ChatOps Culture
Context specific chat rooms replace email threads
Teams share information in these context-specific rooms
Teams develop a shared vision and establish a perspective on how their work impacts
others
Bot-based integrations automate work, done through command-line terminal
Processes evolve into new chat-based workflows
Quick Fact
Like any piece of software, it is as secure or insecure
as it is designed and implemented.
ChatOps is being used even in compliance (PCI, ISO,
HIPPAA, etc.) driven organizations.
Chat Client
Chat Client is the keyplayer of ChatOps, where business wide collaboration happens.
Through this interface, users can communicate and share files with each other instantly.
Most Chat clients offer a wide range of third‐party integrations that can allow users to
receive notifications and begin interacting with services for information without the help
of a bot.
Popular Chat Clients: Slack, HipChat, flowdock and Campfire
Chatbots
Chatbots can help DevOps teams in automating repetitive tasks which are otherwise
done manually by team.
Scheduling assistants
Activity reports
Team productivity ledgers
News Broadcast
Emojis ... thousands of bots can be integrated into chat rooms to post automatic updates
or trigger functionality when prompted.
As team collaboration moves from email to chat, DevOps is trying to automate the
testing and deployment of software using Chatbots.
Popular Chatbots: Hubot, Err, Jirio and Lita
Start Small and Iterate
There are a lot of powerful ChatOps tools, plugins, and extras available, it's
recommended to start simple, experiment and decide which ones to use.
Try various bot integrations and scripts in team chat rooms, and then adapt the ones
that work best for your team.
What is Slack?
Slack is a messaging app for teams. It brings all teams' communication and files in one place,
where they’re instantly searchable.
This video highlights some of the main features of Slack.
If you have trouble playing this video. Please download the root certificate and proxy certificate and
install.
Integrations in Slack
Here is a sneak peek into various integration capabilities available in Slack.
If you have trouble playing this video. Please download the root certificate and proxy certificate and
install.
What is GitHub
GitHub probably does not need any introduction. However, here is a quick refresher on GitHub.
GitHub is a web-based Git repository hosting service, which offers all of the distributed revision
control and source code management (SCM) functionality of Git. Watch this video to know
more!
If you have trouble playing this video. Please download the root certificate and proxy certificate and
install.
GitHub integration with Slack
The GitHub integration for Slack helps in keeping a tab on the repositories.
This integration will issue notifications to specified channel in Slack for following types of
events.
Commit events
Pull requests
Issue events
Deployment statuses
About this Module
Now get ready! Its going to get more Interesting!
Let's dive into ChatOps with some simple hands-on exercises!
To start with, let's learn how to integrate Slack and GitHub.
Exercise#1 - Step 1
Creating GitHub Account
If you do not have a GitHub account, create one by visiting github.com.
Create a Test Repository "helloworld" by Clicking on Start New Project
Choose to Initialize the repository with a README file
Click the button Create Repository
Exercise#1 - Step 2
Creating Slack Account
Create a new slack account using your e-mail address and a trial slack team by
visiting slack.com, as illustrated.
Explore Slack, if you are new to slack. Else, you can skip the starter tutorial.
Exercise#1 - Step 3
Integrate Slack with GitHub
Follow the illustration or the instructions below:
VisitGitHub in Slack’s App Directory.
Click Install.
Select a channel where GitHub events will be posted.
Click Add GitHub Integration.
Click Authenticate your GitHub account.
Choose the repositories you’d like Slack notifications for.
Choose the GitHub events you want to post to Slack.
You can customize the display name for GitHub posts and even add a custom icon.
When you’re done, click Save Integration.
Exercise#1 - Step 4
Test Commit Notification
Create a branch of the helloworld repository
In the branch, select the read me file
Click the pencil icon in the upper right corner of the file view to edit.
In the editor, add a line of text
Write a commit message that describes the changes
Click Commit changes button
This should have posted two updates in the slack channel, about the new branch
creation and the new commit.
Exercise#1 - Step 5
Test Pull Notification
Click the Pull Request tab, and on the Pull Request page, click New Pull Requestt
button.
Select the base as master and the branch for comparing
Review the changes highlighted
Click the Create Pull Request button
Enter pull request a title and brief description of the changes.
Once done, click Create Pull Request!
This should have posted notification in the configured slack channel, updating about
the pull request.
Exercise#1 - Step 6
Test Merge Notification
It’s time to bring your changes together. Merge the new branch into the master branch.
Click Merge Pull Request button to merge the changes into master.
Click Confirm Merge.
Once the merge is done, Delete the Branch
This should have posted notifications in the configured slack channel, updating about
the merge and branch deletion.
End of Exercise#1
Hope this was fun!
Now every time a team member makes a commit or request for pull, you can get to
know and act on it right from your chat window! Isn't that great!
Why unauthed mode?
So far, what we have seen is the scenario where Slack will automatically configure and
manage messages we receive from GitHub. For this, slack had to be given write
permission to public and private repos.
However, when entire team uses GitHub Enterprise and you might not want to grant
blanket permission for Slack to read and write. Instead GitHub app will need to be set
up in unauthed mode.
In this mode Webhooks are used to interact and notify. Now, lets do another hands-on
exercise where Git and Slack are integrated in Unauthed mode.
Exercise#2 - Step 1
Integrate in unauthed mode
VisitGitHub in Slack’s App Directory.
Since GitHub has already been configured, Edit Configuration.
In the Configuration page, click Switch to unauthed mode.
Here you will notice a Webhook URL which will be used in next step.
Exercise#2 - Step 2
Adding Webhook in Git
In GitHub.com, go to the repository that you'd like to monitor.
Click Settings in the right navigation.
Click Webhooks in the left navigation, then Add Webhook.
Copy the Webhook URL from Slack and paste it for Payload URL.
Select Content type, to be application/json.
Confirm SSL verification is turned on.
Click Add Webhook.
Return to your Slack setup page and click Save Integration.
Exercise#2 - Step 3
Test the Integration
Now, try to Create a Branch of your repository in GitHub.
Edit the Readme page and Commit changes.
As we had done in the Exercise 1:
Create a Pull Request
Merge the Pull Request
Delete the Branch
Check the configured slack channel for the notification triggered during this process.
Configuring Git Notifications
Now that you have integrated Slack and Git, go to:
Git Project > Settings > Webhooks > Edit .
Choose Let me select individual events for Which events would you like to
trigger this webhook?
Now, you will see a list of events that can be selected to trigger a notification in slack.
In this module, we will work on a case study to understand these event notifications.
Exercise#3
Assume, you need to add a new feature to an existing project.
A userstory for this feature would have been created by the Stakeholder/BA.
A core project team of developers, designer and tester would start working on this
feature.
Not all notifications are equally important for both these groups. Hence,
notifications need to be configured such that, both these groups receive only the
notifications relevant for them.
Exercise#3 - Step 1
Create New SlackChannels
Create a new branch starfeature in GitHub.
Create a private channel starprojectteam in Slack. Only the core project team
members have access to this channel.
Create another private channel stakeholders in Slack. The stakeholders, BAs and
Scrummaster would be part of this channel.
Exercise#3 - Step 2
Create Git Webhooks
In slack, click on Explorer > Apps & Integration > GitHub > Install
Create two separate Git integrations in unauthed mode using Webhooks for the new
channels
Configure Event triggers in the GitHub Webhooks to trigger only the notifications
relevant to the team.
This should have triggered a notification on respective channel updating about the
newly added integration.
Exercise#3 - Step 3
Event Notifications for Project Team
Star Project team members need to be aware of what each of their team members are
working on and when they are committing. Hence for starprojectteam enable
notifications for events like
Commit
Branch created/deleted
Deployment, Deployment status
Issues opened, comment
Member added/removed
Pull request open, review, comment
Update Push to repository
Exercise#3 - Step 4
Event Notifications for Stakeholders
Unlike core project team, for Stakeholders and Business users, not all events are
important. For stakeholders enable notification for events like
Deployment, Deployment status
Issues, Issue comments
Milestones
Pull Request, review, comment
Get Ready for a Quiz
Hope you were able to follow the steps detailed so far and completed creating the new
channels and webhooks.
Next we will have few simple questions based on this integration. Good Luck!
Bot in ChatOps
Bots have a plethora of abilities through a very robust message system and well placed
hooks to various other tools. Bots can:
Send reminders
Post images
Translate text
Deploy code
... possibilities are many.
Bots can dramatically improve and reduce user efficiency depending on how it is used.
Popular Chatbots
Hubot: Written in Node.js, Hubot executes commands written in JavaScript or
CoffeeScript. Has extensive library of plugins from community.
Lita: Written Ruby, Lita uses the Ruby ecosystem's standard tools (RubyGems and
Bundler) for plugin installation and loading.
Err: Is an extensible chatbot that uses Python scripts to execute instructions
Jirio Jirio is a specialized bot that integrates with Slack and JIRA as webhook and
provides a seamless approach to manage issues from Slack.
There are many other bots, with each having different plugins, pick the right bot based
on your project ecosystem.
More about HuBot
Hubot is widely gaining popularity among DevOps teams. It was first developed
by GitHub in CoffeeScript on Node.js.
Few highlights which is making it a favorite:
Regularly updated by Github
Large number of prebuilt scripts
Incredibly simple to add new functionality
Ability to leverage large number of packages available for the Node.js
Really simple and easy to setup
Support for most of the popular chat servers
We will learn in more about Hubot in future courses.
Simple Jirio bot Integration
To get a better understanding of Chatbot, over next few cards, we will look at
integrating Jirio Bot with Slack.
Jirio bot integrates with Slack and JIRA as webhook and provides a seamless Slack and
JIRA integration for creating, managing and viewing JIRA issues from Slack.
To start with,
Visit https://jira.atlassian.com and create a free Jira account.
Create a sample project hello-world with project key HELLOWORLD.
Adding Jirio to Slack
Visit https://jirioslackapp.com/
Click Add to Slackbutton.- Enter your Jira Instance URL and Project key.- Leave
Public Notifications and User Authentication checked.- ClickNext andAdd
Application Link.- Follow the wizard and Authenticate JIRA.
Testing Jirio Integration - 1
Now, lets do some simple exercises to ensure there is a Two way
communication established between Jira and Slack.
To begin with,
Go to slack channel and enter /jirio help.- This should list a number of slash
commands.
Testing Jirio Integration - 2
Create a new issue using the syntax below
/jirio create story Readme needs a Revamp
An update from JIRIO to Slack with the new Story ID and link should be messaged.
Testing Jirio Integration - 3
Update Issue Priority to Highest
/jirio update <<Issue ID>> :priority Highest
Assign the issue to your self by clicking on Assign to me
Check for the Issue status in JIRA
Testing Jirio Integration - 4
Go to your JIRA Instance and Click Issues >*** Current Search***.
Select the Issue ID that you had created from Slack. Update the Status to Done.
This should have triggered a notification to the configured channel in Slack.
Chatbots Summary
Hope that gave you a fair idea about Chatbots and how one can use simple slash
commandsto manage issues in JIRA directly from chat window. This was just a
glimpse of the capability of Chatbot.
Do explore other features and other Chatbots. You might find a number of interesting
bots readily available to make your life simple!
Quick Fact
Embrace adoption: Teams are usually reluctant to
change and hang on to good old emails. Start small
with pilot teams, get buy in, and create evangelists
within the company.
Fine-tune notifications: Quite often, too many
notifications are pumped into the chats. Utilizing bots
to automate and notify people only for things that are
relevant and need to act on right away.
Choosing the Bot: Many a times, programming
language preference drives this decision. Later they
implement custom Bot plugins, leading to piles of
scripts. Which is WRONG.
Base Chatbot decision on the Automation Library available.
Start small and iterate: Try various bot integrations
and scripts in chat rooms, and then stick with the
ones that work best for your team. There may be
some trial and error, but it works!
Build Automation Library: In ChatOps solution,
quite often you will find that the exact integration you
need are either:
Not there
Not doing what you need
Not doing it the way you want it
Some of the integrations, incidentally, will be custom
scripts against proprietary tools. Supporting it natively
is a stretch for Chat clients like Slack or HipChat.
Don’t limit yourself to what’s out of box in your Chat platform. Own your ChatOps
commands. Use a bot to expose your automation library to a chat platform.
A bot gives you that level of control, and
integrates smoothly with the Chat services.
ChatOps Course Summary
In this course, we have learnt in detail about:
What is ChatOps
Chat Clients andin particular Slack
Chat Bots and in particular Jirio
Chat Client integration with GitHub
Chat Client integration with Jira
Which of the following tools can not be integrated into ChatOps.
Jira
Jenkins
GitHub
Eclipse
Which of the following Bots are written in Ruby
Lita
Jirio
Hubot
Err
ChatOps is a collaboration model which offers a single and persistent location, for
___________ to collaborate with each other.
People, Bots and Tools
People
People and Tools
People and Bots
Through ChatOps, collaboration is tied to the IT systems and processes, therefore
making it more ____________
Traceable
Contextual
All the options mentioned
Efficient
Through ChatOps, communication can be bi-directional. i.e. users can submit
commands from the chat room to the bots, which direct the commands to the
respective systems; the systems can automatically push status to the chat room
directly.
True
False
What is ChatOps ?
Tools
Technology
Collaboration Practice
All the options mentioned
Which of the following activities can be automated through ChatOps
Make Server Configuration Changes
Creating and Tracking Issues
Troubleshooting Issues
All the options mentioned
Which of the following is not a ChatClient
Campfire
Flowdock
HipChat
Lita
Which of the following is the main consideration while choosing a Chatbot?
Plugins available
All the options mentioned
Ease of adding new functionality
Extensibility
"ChatOps primary aim is to move conversations away from e-mail and into business
chat tools." Is this statement correct?
True
False
Which of the following are the technical benefits that the teams can realize by
Increased speed of actions
Increased automation
Improved security
All the options mentioned
Which of the following is not an ideal target to automate through ChatOps
Deploying Code to Servers
Auto Scaling Servers
Broadcast messages to team
Logging Issues
Few Channels in Slack are listed with a lock symbol in the Explorer, because these
channels are ___________
Public
Personal
Exclusive
Private
Can Chatbot be used by a restaurant to take customer orders and make menu items
suggestions.
Yes
No
Through Chat Client, users can
Share Documents
Broadcast Deployment Schedule
All the options mentioned
Collaborate on Problems