Freigeben über


Create a consumer service for service hooks

TFS 2017

With service hooks, you can do tasks on other services when events happen in your project. For example, create a card in Trello when a work item gets created or send a push notification to your team's mobile devices when a build fails. Service hooks can also be used in custom apps and services, as a more efficient way to drive activities when events happen in your projects.

Tip

Check out our newest documentation on extension development using the Azure DevOps Extension SDK.

How service hooks work

Service hook publishers define a set of events. Subscriptions listen for the events and define actions to take based on the event. Subscriptions also target consumers, which are external services that can do their own actions, when an event occurs.

Service hooks diagram

Custom consumer service

This article walks through developing an extension that implements a sample consumer service that includes:

  • Supported events that trigger actions to be taken
    • Code pushed
    • Pull request created
    • Pull request updated
  • Supported actions to take when events occur
    • Do action

Note

This article refers to the home directory for your project as "home".

Sample consumer service

Create the extension

  1. (Optional) Add an icon - a square image in the images folder that identifies your extension. It's displayed in the Marketplace and when someone installs your extension. You don't need to add an icon for your extension to work, but you can use it alongside your extension name, like in the following image.

Note

Name the image logo.png, or remove the "icons" sections from the manifest file if you wish to skip this step.

Sample logo.

First extension sample.

  1. Create the manifest file and populate it. The manifest file defines both your extension and the consumer service.

    Create a json file (vss-extension.json, for example) in the home directory of your extension with the following contents:

{
    "manifestVersion": 1,
    "id": "tools",
    "version": "0.1.0",
    "name": "Fabrikam Tools",
    "publisher": "fabrikam",
    "targets": [
        {
            "id": "Microsoft.VisualStudio.Services"
        }
    ],
    "categories": [
        "Azure xxx"
    ],
}

Note

Make sure to update the publisher property. Valid values for categories are: Azure Repos, Azure Boards, Azure Pipelines, Azure Test Plans, and Azure Artifacts.

For a consumer service, the following properties are required:

Property Description
manifestVersion Number corresponding to the version of the manifest format.
id Unique ID for your consumer service.
version String specifying the version of the consumer service.
name Name of the consumer service.
publisher Identifier of the publisher.
categories Array of strings representing the categories your consumer service belongs to. For more information, see Required attributes.
targets Products and services supported by your integration of extension. For more information, see Installation targets.

Next steps