Integrate Azure Pipelines With Google Workspace

Sachith Kasthuriarachchi
3 min readOct 2, 2021

--

Azure pipelines is a prominent choice when implementing continuous integration (CI) and continuous deployment (CD). For a large organisation with multiple component products, it will eventually be very hard to go through each pipeline to identify what components has problems. In that case it would be really easy and productive if we could get an alert to our normal chat space as soon as a pipeline fails (or succeeds with issues). This article describes of how to implement this scenario using Azure pipelines with google chat web-hooks.

The first step is to create a pipeline for our CI CD job. The pipeline definition will look like follows.

Here, I have added a simple testing script which tries to cat the contents of chat-notify.yml file. This step should fail since there is no such files (extension should be .yaml instead of .yml).

If I explain the above file a little more, this file lies in the following github repository.

Under the Testing1 job, the pipeline checkouts to this repository as the first step (checkout: self ). Then the script with cat command runs with the working directory set as blog-samples which is the repository name.

The ChatAlerts job is dependent on the Testing1 job. According to the condition this job will only run if the depending job fails. The pipelines/templates/notify-template.yaml contains the steps that needs to be executed to post a message in google chat space.

This template just executes the following shell script.

The above shell script just execute a POST request to our google chat web-hook url specified in the chat-notify.yaml(line 20). The body contains all the formatting of how the message is gonna be posted in our chat-space. You can learn more about these formatting here.

Now, only thing left is creating an incoming web-hook in your chat room. For that please open your chat room and click the drop down menu near the name of the chat room and click Manage Webhooks.

Then, provide a name and avatar url for your webhook. You can find some nice icons in icons8 website.

Click save and copy the webhook url.

This is the webhook url you need to specify in the chat-notify.yaml file (in line 20).

Boom, Now you have set your azure pipeline to send alerts to your favourite chat room!

--

--