Visual Studio Team Services – Creating a build pipeline (Part 6)


In part 1 a basic Azure Web App website was built and deployed using VSTS Build and Part 2 illustrated how additional files could be included when building a web project.  Part 3 demonstrated how Gulp could be added to the VSTS Build  pipeline.  In part 4 Load Testing was added to the build pipeline and part 5 added slots to help smooth the build process and limit downtime.  This post will look into using service hooks in VSTS, and as an example, will integrate with an existing Slack team in order to post messages when a build fails.

Service Hooks

VSTS provides service hooks for reporting events to external systems.  The events and supported actions vary depending on the external system.  For example, when integrating with Trello, a popular on-line collaboration tool, the following events and actions are supported:

Events

Actions

Build completed Create a card
Code pushed Create a list
Pull request created
Pull request updated
Team room message posted
Work item commented on
Work item created
Work item updated

There are many services built in and additional services that can be targeted by service hooks are available in the Visual Studio Marketplace.  Service Hooks are well documented and each service shows the sequence of steps required to configure them:

vsts1

References

Slack

As an illustration of service hooks, let's add a slack notification when a

The first step is to configure slack for integration with VSTS.   Within the slack team, select the Apps & integration option:

vsts2

Search and find the Visual Studio Team Services application and Install:

vsts3

In the option to Post to Channel, an existing channel or the ability to create a channel can be selected.

vsts4

After the application is configured, slack provides control for removing or disabling the integration as well as setup instructions.

vsts5

Note: in the setup instructions and in the Integration Settings is the Webhook URL which is needed in the VSTS setup:

vsts10

 

Setting up a Service Hook in Visual Studio

Slack and VisualStudio.com both provide setup instructions so in order to make this post a bit more interesting, let's setup a service hook only for when a build ends.  In VSTS, select the Service Hooks menu from within the build project:

vsts7

After selecting Slack, you can then specify the event and filters.  In this example, only Failed builds will generate a message:

vsts8

The final step in the wizard requires the Slack webhook address and a convenient way to test the integration:

vsts9

Summary

Service Hooks is a great feature for integrating the activity of VSTS into external applications.  There are many out of the box services available as well as the ability to subscribe to VSTS to receive notifications about build events.  Service Hooks and other features allow teams to handle events as they happen and not just when reported or stumbled upon.  For example, with the Slack application running, alerts in the Action Center are immediately brought to the attention of the devops as illustrated below:

vsts11

 

 

 

 

Comments (1)

Skip to main content