GitLab is a web-based DevOps lifecycle tool that provides a Git-repository manager providing wiki, issue-tracking and CI/CD pipeline features, using an open-source license, developed by GitLab Inc.
Recently, Gitlab was recognized as a market leader on the 2019 Forbes Cloud 100 list. And that didn't come as surprise since it is already used by many of the Fortune 500 companies with a complete software development lifecycle.
Google Hangouts Chat popularly know as Chat is an in-house communication platform for enterprise users that comes bundled with G Suite. It has handy features like hangouts meet, google drive, calendar, etc. And all this comes at no additional cost which makes it a good choice for companies who have already invested in G Suite.
In this article, we will go through the steps required to trigger notifications from Gitlab to a room in Hangouts Chat. This will help the team stay updated to events like code push, merge, etc.
Step 1. Creating a project in Gitlab
The first step is to create a new project on Gitlab and connect it to your project just like how you would do for any git projects. If you are using an existing project you will need owner or maintainer permissions for the project since developer permission is not enough for accessing settings tab in a project.
Step 2. Creating a Room in Chat
The next step is to create a Room in Hangouts chat. You can add all stakeholders of the project into this room to make sure that everyone is kept in the loop about the changes. You can also use an existing room in case you don’t want to create another one for a project, but I would suggest keeping this one separate since it might get flooded with notifications depending on the triggers you have enabled.
Now click on the group name and select the Configure Webhooks option.
Enter a Webhook Name and paste an avatar URL to customize the looks of how your messages would appear. Try to give meaningful names such as project name or names like eg-
Gitlab Notifier in case you are using this in a crowded group to highlight messages easily, here I am just gonna use
Test Project with the Gitlab logo. Once this is done copy the webhook URL by clicking on the copy symbol.
Step 3. Adding Webhook to Gitlab
Go back to Gitlab and from the options in the settings tab, select integrations. If you scroll down on this page you will see almost all popular tools listed in project services, from this choose Hangouts Chat.
Once you select this, you get a set of options to customize your notification trigger conditions. You will have the following options-
- Event triggers
You can trigger the notification for specific events like push, merge requests, etc.
- Branches to notified
You can also select the branches for which you need to receive notifications from the four options given- All branches, Default branch, protected branches, Default branch, and Protected branches.
- Notify only broken pipelines
Send notification only for broken pipelines.
In the Webhook input box, you have to paste the webhook URL copied from hangouts chat earlier.
Once you are done click on Test settings and Save changes. This will save the settings and immediately send a test notification to your hangouts chat room.
That’s it, now you will start receiving notifications for all the events and branches you selected into the room.
You can keep a separate room for each project notification, configure multiple webhooks from multiple projects into one Chat room, or integrate them into a project room where other discussions happen based on your convenience and requirements. But for the later two cases make sure that it doesn't get spammed with these notifications in the future.