如何自动将Work Items链接到Build?及相关关联查询问题咨询
Great question! Let's break down your concerns step by step, since all the functionality you're looking for is absolutely achievable in TFS:
一、配置Work Items与Build的自动关联
You’re right that PRs already link to Work Items and update those items with commit links once merged—but to get those Work Items automatically tied to your Builds, you just need a quick pipeline setting:
- Enable automatic linking in your Build Pipeline
Navigate to your Build Pipeline’s settings, open the Options tab, and look for the setting labeled something like Automatically link work items included in this build (the exact wording might vary slightly by TFS version). Check this box, and going forward, any Build that includes commits tied to Work Items (via your PR requirement) will automatically create that link between the Build and the corresponding Work Items. - For Release Pipelines (if applicable)
If you’re using Releases, you can find a similar auto-linking option in your Release Pipeline’s settings to ensure Work Items are tied to your released builds too.
二、修复分支提交历史中Build列为空的问题
That empty Build column happens because your commits haven’t been associated with a Build yet. Here’s how to fix it:
- Ensure your Build Pipeline has CI triggers enabled for the target branch. This way, whenever a new commit (from a merged PR) lands in the branch, a Build automatically runs, and once completed, the commit history’s Build column will populate with the corresponding Build ID.
- If you’re running manual Builds, make sure you select the correct branch when triggering the Build. Once the Build finishes processing that branch’s commits, the Build column in commit history will show the relevant Build details.
三、查看特定Build包含的Work Items
You’ve got two straightforward ways to do this:
1. 查看Build详情页
在TFS的Builds hub找到目标Build记录,进入详情页后,找到Work Items标签(通常和Summary、Logs、Artifacts标签并列)。这个标签会列出所有与该Build包含的提交关联的Work Items,适合快速查看。
2. 创建自定义Work Item查询
如果需要更灵活的筛选(比如结合Build关联和其他Work Item条件),可以使用TFS的查询工具:
- 新建一个Work Item查询
- 添加筛选条件:在Linked Work Items下,设置Link Type为"Build",然后选择目标Build的名称或ID
- 运行查询,就能得到所有与该Build关联的Work Items列表
With these settings in place, you’ll have full visibility into the connection between your Builds, commits, and Work Items—exactly what you’re looking for!
内容的提问来源于stack exchange,提问作者Mike Therien

