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?
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.
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:
You can add workitems by adding then by id or searching on existing queries. You can add one or more workitems.
After that, VSTS will automatically link the changeset and workitem.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With