首先,您可以在签入更改时关联工作项,然后在验证构建后更改集将关联到相应的工作项。
其次,您可以使用update work item REST API 将变更集与工作项相关联:
例如:
PATCH https://[account].visualstudio.com/DefaultCollection/_apis/wit/workitems/[work item id]?api-version=1.0
内容类型:application/json-patch+json
主体:
[
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "ArtifactLink",
"url": "vstfs:///VersionControl/Changeset/[changeset ID]",
"attributes": {
"comment": "apitest",
"name": "Fixed in Changeset"
}
}
}
]
您可以使用 Build.SourceVersion 来获取 ChangeSet。 Build variables
通过 PowerShell 任务获取 chageset 的简单示例:
参数:-v $(Build.SourceVersion)
脚本:
param(
[string]$v
)
Write-Host $v
关于在构建期间调用 REST API 的博客:Calling VSTS APIs with PowerShell