Microsoft Teams
  • 23 Jan 2023
  • 1 Minute to read
  • Dark
    Light
  • PDF

Microsoft Teams

  • Dark
    Light
  • PDF

Article Summary

Using OtterScript to Connect BuildMaster to Teams

Microsoft Teams is an enterprise communications platform developed by Microsoft that is part of the Microsoft 365 family of products. BuildMaster can be integrated with Teams by posting messages to Microsoft Teams channels via an Incoming Webhooks Connector built in to Teams.

In this page, we will show you how BuildMaster can post messages to Teams by using a Post-Http operation in OtterScript. See the OtterScript example blow.

Configuring the Teams Webhook

Microsoft Teams makes creating webhooks very easy. Within Teams, navigate to the channel you want and click the button with the three dots. Select Connectors and Incoming Webhook.

TeamsConnectorAdd1.png

Name your webhook, optionally give it a custom image.

TeamsConnectorConfig1.png

Teams will create a URL that you will need to copy and paste into your OtterScript.

TeamsConnectorConfig2 1.png

In BuildMaster, locate the OtterScript plan, module, pre-deployment script, or post-deployment script you want to send the message from. Then, add a new Post-Http operation that will be sent to the above URL. For the TextData property, you will need to include the Teams message JSON. Your JSON message can leverage BuildMaster's variables and variable functions in the message. See the OtterScript example below.

Example: OtterScript to Post a Message to Microsoft Teams

This is an example Post-Http operation in OtterScript to send a Teams message to an Incoming Webhook Connector configured in Teams.

Post-Http <URL from Teams WebHook Configuration>
(
    ContentType: application/json,
    TextData: >>{
  "@context": "https://schema.org/extensions",
  "@type": "MessageCard",
  "themeColor": "F6A52B",
  "title": "BuildMaster - New Build $ApplicationName $ReleaseNumber.$BuildNumber",
  "text": "**New Build** $ReleaseNumber.$BuildNumber has completed.  View it at [Build $BuildNumber]($BuildMasterUrl(release))."}>>
);

Microsoft Teams Message JSON {#teams-message-json}

Teams' message JSON is more complex because they use Cards and therefore can be tedious to configure. Visit Microsoft's connectors documentation page to get some sample syntax, or just test your Teams webhook by copy/pasting the following sample syntax:

{
  "@context": "https://schema.org/extensions",
  "@type": "MessageCard",
  "themeColor": "F6A52B",
  "title": "BuildMaster - New Build $ApplicationName $ReleaseNumber.$BuildNumber",
  "text": "**New Build** $ReleaseNumber.$BuildNumber has completed. View it at [Build $BuildNumber]($BuildMasterUrl(release))."
}

Note: The $BuildMasterUrl function is only available in BuildMaster 6.2.21+. Check your functions reference inside of BuildMaster for more information.


Was this article helpful?

What's Next