Search code examples
azure-devopstfvc

How to link changeset to workitem?


We are using Visual Studio Online and TFVC [not Git] for source control, When we commit our code we always check in the work item id or Bug number as part of checkin comment like following,

#1234 Fixed console error.

Is there a way we can automatically link these changesets to workitem?


Solution

  • No, there isn’t such feature in Visual Studio to link changesets to work item automatically, through comment or UI to link work item manually is the simple way.

    Update:

    Associate work item to changeset through Work Items REST API:

    PATCH https://{account}.visualstudio.com/DefaultCollection/_apis/wit/workitems/{work item id}?api-version=1.0
    

    Content-Type: application/json-patch+json

    Body:

    [
      {
        "op": "add",
        "path": "/relations/-",
        "value": {
          "rel": "ArtifactLink",
          "url": "vstfs:///VersionControl/Changeset/{changeset id}",
          "attributes": {
          "name": "Fixed in Changeset"
          }
        }
      }
    ]
    

    On the other hand, this sample may benefit you: TFS Api to associate work item with check-in using comment tags