Microsoft Teams Integration

Hey All!

UPDATE: I’m going to keep the rest of the post here, in case you need to have more than what the default notifications allow. However, Harness recently released an official integration for Microsoft Teams: https://harness.io/2020/05/welcome-to-the-harness-chatops-family-microsoft-teams/.

I’ve had a few conversations around integrations with Harness and other tools, what is and is not supported, and even when certain integrations will be coming. One of the great things about a Software-as-a-Service like Harness is that you get rapid integration support with use-case-directed development.

Obviously, we will need to supplement a stop-gap for some of these integrations in the meantime. The technology integration that this post covers will be Microsoft Teams Notifications

There is a way to do these notifications via an Email, so definitely check that out first, as that might give you everything you are looking for.

In the case that the Email is not as robust as you need, these steps will walk through the notification process using a Webhook.

Microsoft Teams Incoming Webhook

The first step is to either select or create a channel in Microsoft Teams

The next step is to click the three dots to the right of the channel name and then select Connectors

In the Connectors page, search for Incoming Webhook, give it a name (like Harness), and upload the desired image

Once that is done, it is time to build out the desired cURL payload that you want to use for the notification

Notification Command

First, we will build out the command to be the notification. Here is a github link to the command I am using.

NOTE: The entire curl command must be a single line

Let’s break down this command:

  • WEBHOOK_URL - The Webhook URL from that you set up in the Microsoft Teams channel
  • ${workflow.name} - Has Harness plug in the name of the Workflow into the channel title and the Workflow Name Key:value pair
  • ${msg} - Takes a user-specified messaged (i.e. Started, Finished, Rolling Back, etc.) and add it to the end of the Title
  • ${deploymentUrl} - Passes the URL of the deployment to the channel
  • ${service.name} - Passes the name of the Harness Service to the channel
  • ${artifact.metadata.image}:${artifact.metadata.tag} - Passes the Artifact Name and Tag to the channel
  • ${env.name} - Passes the Environment Name to the channel
  • ${deploymentTriggeredBy} - Either the person or trigger that was used to do the deployment

The command itself is broken down as follows:

  • Title is the message header in Microsoft Teams
  • Theme Color is the colored line above the message header (25ADE4 is the Harness Blue from our website)
  • Summary doesn’t actually show in Microsoft Teams, but it is required for the webhook to work
  • Sections and Facts are tied together for the key:value pair list to be put in the channel

Harness Setup

Start by going to the Template Library in Harness (Setup > Template Library) and create a new SSH Command

Add the command in the script window and add a msg variable to the bottom of the form

Once that is done, we can link that script in the Workflow for proper notifications

Workflow Integration

Go to the desired phase, add a new command, and select Select from Shared Template Library in the top right, and select Link to the right of the desired template

Once that is linked in the desired spot, the only thing required is to put in the appropriate Message info.

If you want to use this in a more advanced way as well, you could put this in the rollback steps!

You’re all set to receive Microsoft Teams notifications!

I will update this post as some functionality is improved or if new issues arise.

Don’t forget to Comment/Like/Share!

4 Likes

Awesome contribution!

1 Like

Awesome post Bryan! We have many customers who have been asking for an integration around MS Teams.

2 Likes

This is great. I just integrated this today. The instructions were super simple and I had it up and running in no time.

2 Likes

Thanks to all the Community demand and @sneakyaneurysm’s due diligence, we have official Microsoft Teams support now.

Blog Post:
https://harness.io/2020/05/welcome-to-the-harness-chatops-family-microsoft-teams/

Cheers!

-Ravi