Using Telegram to monitor your Gitlab pipelines

Categories:

How to be aware of what your pipelines are doing without wallboards and separate browser windows

As a Freelancer I often work with customers who have their own servers, but leave most of the technical work to me. I don't enjoy working directly on servers that much, so the first thing I do when a new server needs to be configured, is installing a Gitlab Runner.

 

Setting up pipelines

This service is then connected to Gitlab.com, the customers Gitlab instance or my own self-hosted Gitlab. Then I set up a deployment pipeline which matches to the project. So for PHP projects I usually choose TYPO3 Surf to execute actual deployments. Deployer is also an option, but I just got lately into using it more and primarily use it of other tasks. For other kinds of projects you would of course choose the tool which matches best. For Ruby projects it could be Capistrano, or you just have a bunch of Shell/Docker scripts.

After setting up a pipeline in Gitlab to automatically run builds, tests, deployments and other tasks, my project workflow is usually only based on pushing data to Gitlab. So I push via Git and then start working on the next task. Gitlab then handles the rest by communicating to the Gitlab Runner that is running on the server. The runner will then build the project, run some tests and finally deploy new releases. And the whole thing might work out or fail...

How to know what the pipeline is doing

So for quite a while I was looking for a way to monitor what happens after builds succeed or fail. I'm usually interested in any kind of failure in any stage of the pipeline, to start fixing the issue. Or success messages, when a deployment went through, after which I like to run some manual tests and inform the customer of the finished update.

Of course you can simply go to the Gitlab instance and watch the pipeline view and see what's going on. You can also setup awesome wallboards on separate screens, or have a Raspberry PI to create some interesting output. But all these things were to time consuming for me, or didn't work out if I'm working from somewhere else.

Therefore I was searching for a way to passively monitor the pipelines with the least amount of distraction. After quite some time of searching I found out that a Gitlab integration for the Telegram messenger exists. It's called Integram, is Open Source and works really well. It  also supports the todo list Trello and the code management tool Bitbucket.

Using Integram

Integram basically offers a chatbot for Telegram. This bot allows you to interact via messages with your Gitlab instance. You can add hooks to the projects that should be connected and the bot will then inform you of the progress of these projects pipelines.

As Telegram offers apps for iOS, Android, Mac OS X, Windows etc.. you can receive those messages everywhere. For example, I do a git push with a new release tag, then go make a coffee in the kitchen and a few minutes later my Apple Watch notifies me that the triggered deployment when through.

If you don't trust the Integram bot, you can also host the service yourself. This way you can keep the whole CI infrastructure to yourself.

Of course you can also attach the bot to a group chat, so a whole team can be informed.

Find the information on how to set it up in their Github repository. You basically setup the bot in your Telegram chat and add service hooks to your individual project repositories in Gitlab. The bot will help you through the whole process.

Summary

In my opinion, the Integram bot is a non-intrusive way of being informed of builds & deployments. As Telegram allows you to treat the chatbot like any other user, you can even mute it for a while if necessary. 

If you or your company uses Slack, there are of course integrations which might suit you better.