Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 647
iraSenthil Avatar asked Mar 06 '23 16:03

iraSenthil


2 Answers

When you check-in using TFVC, you can define a check-in policy and specify that people are required to link workitems to their check-ins.

You can do this in Visual Studio Team Explorer -> Settings and under Team project go to Source Control.

enter image description here

So every time someone tries to check-in code, they have to associate a work item. This can be done directly from within Visual Studio pending changes.

Updated

Doing that will associate your changeset with your workitem, as follows:

enter image description here

You can add workitems by adding then by id or searching on existing queries. You can add one or more workitems.

enter image description here

After that, VSTS will automatically link the changeset and workitem.

like image 62
Rodrigo Werlang Avatar answered Mar 15 '23 13:03

Rodrigo Werlang


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

like image 31
starian chen-MSFT Avatar answered Mar 15 '23 15:03

starian chen-MSFT