Rediger

Del via


Contribution model

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022

Extensions add capabilities to Azure DevOps through contributions and contribution types declared in the extension manifest. A contribution type defines a contract — the properties and behavior that contributions of that type must implement. A contribution is a concrete instance of a contribution type (for example, a hub or a build task).

Tip

If you're starting a new Azure DevOps extension, try these maintained sample collections first—they work with current product builds and cover modern scenarios (for example, adding tabs on pull request pages).

If a sample doesn't work in your organization, install it into a personal or test organization and compare the extension manifest's target IDs and API versions with the current docs. For reference and APIs, see:

For more information, see:

Contribution types

A contribution type defines the properties and rules that contributions of that type must follow. Contribution types can extend other contribution types, inheriting their properties.

Common built-in contribution types include:

  • ms.vss-web.hub — a page in the web UI
  • ms.vss-web.action — a menu action
  • ms.vss-distributed-task.task — a build/release task

Each property definition in a contribution type specifies:

  • type — the data type (for example, string, boolean, integer)
  • required — whether the property must be provided
  • default — an optional default value

Contribution type example

A contribution type declaration in a manifest looks like this:

{
  "contributionTypes": [
    {
      "id": "hub",
      "name": "Web Access Hub",
      "description": "A hub that appears in the hubs menu at the top of web pages.",
      "properties": {
        "name": {
          "description": "The text to display for the hub",
          "type": "string",
          "required": true
        },
        "uri": {
          "description": "URI of the contents of the hub page",
          "type": "string",
          "required": true
        },
        "order": {
          "description": "Optional ordering value indicating the hub's position within the hub group",
          "type": "integer"
        }
      }
    }
  ]
}

Contributions

A contribution is an instance of a contribution type. For example, the Queries hub under the Work hub group is a contribution of type ms.vss-web.hub, and the Publish Test Results build task is a contribution of type ms.vss-distributed-task.task.

Every contribution must specify a type and provide values for any properties required by that type.

Contribution example

The following hub contribution declaration in an extension manifest adds a hub named "Explorer" to a build hub group:

{
    "contributions": [
        {
            "id": "build-explorer-hub",
            "type": "ms.vss-web.hub",
            "targets": [
                ".build-hub-group"
            ],
            "properties": {
                "name": "Explorer",
                "uri": "/_build",
                "order": 22
            }
        }
    ]
}

Target contributions

A contribution can target one or more other contributions, creating a parent-child relationship. The system discovers these relationships at runtime to determine what to render. For example, a hub contribution targets a hub-group contribution so the system knows which hubs belong to which group.

{
    "id": "build-explorer-hub",
    "type": "ms.vss-web.hub",
    "targets": [
        ".build-hub-group"
    ]
}

When the hub group renders, the system queries for all hub contributions that target it to determine which hubs to display.

Contribution identifiers

Every contribution and contribution type must have a unique ID within its extension.

A fully qualified identifier has three parts separated by dots (.):

Part Example
Publisher ID ms
Extension ID vss-web
Contribution/type ID hub

Full identifier: ms.vss-web.hub

Within the same extension manifest, you can use relative references — a dot followed by the contribution ID. For example, .hub is a shortcut for ms.vss-web.hub when used inside the vss-web extension.