You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过VSTS查询或REST API获取两个版本间的工作项以生成发布说明?

Absolutely! You can absolutely pull work items between two versions (whether they’re releases or sprints) using either Azure DevOps’ built-in Query Editor or its REST API—both will let you build that Features > Stories > Tasks hierarchical list way faster than manual UI digging. Here’s how to tackle both approaches:

Using the Azure DevOps Query Editor (No-Code Solution)

This is perfect if you need a quick, one-off list without writing any code:

  • Head to Boards > Queries > New Query to create a new query.
  • Select the Tree of Work Items query type—this is critical because it automatically displays work items in their natural parent-child hierarchy (Features → Stories → Tasks).
  • Add filter clauses to target work items from your two versions:
    • If you’re working with releases: Add a clause like Fixed In Release In [Your Old Version], [Your Current Version]. Use Was Ever In Release instead if you need to include items that were moved between the two versions.
    • If you’re using iterations (sprints): Use Iteration Path In [Old Iteration Name], [Current Iteration Name].
  • Narrow down the work item types to only what you need: Add a clause Work Item Type In Feature, User Story, Task.
  • Run the query—you’ll see the nested hierarchy exactly as you need it for release notes.
  • Export the results as CSV/Excel, or just copy-paste the indented tree directly into your document (the UI preserves the hierarchy formatting).
Using the Azure DevOps REST API (For Automation/Scalability)

If you want to automate this process (e.g., generate release notes programmatically), the REST API is the way to go:

  1. Get your version IDs first:

    • For releases: Call GET https://dev.azure.com/{organization}/{project}/_apis/release/releases?api-version=7.1-preview.8 to list all releases, then grab the id values for your target versions.
    • For iterations: Use GET https://dev.azure.com/{organization}/{project}/_apis/work/teamsettings/iterations?api-version=7.1-preview.1 to fetch iteration IDs.
  2. Query work items with parent-child links:

    • Use a WIQL (Work Item Query Language) query to pull relevant items. Example WIQL:
      SELECT [System.Id], [System.Title], [System.WorkItemType], [System.Parent]
      FROM WorkItems
      WHERE [System.TeamProject] = @project
        AND [System.FixedInRelease] IN ('Release v1.0', 'Release v2.0')
        AND [System.WorkItemType] IN ('Feature', 'User Story', 'Task')
      
    • Send this query via the API: POST https://dev.azure.com/{organization}/{project}/_apis/wit/wiql?api-version=7.1-preview.2 (pass the WIQL in the request body as JSON).
  3. Build the hierarchical structure:

    • For each work item in the response, map it to its parent using the System.Parent field.
    • Write a simple script (Python, PowerShell, etc.) to group Tasks under their parent Stories, and Stories under their parent Features.
    • Pro tip: Use the $expand=relations parameter in the work items get API to fetch parent details in a single call, saving you from extra requests.

Either method will eliminate that tedious manual association work you’re dealing with now. Pick the one that fits your workflow best!

内容的提问来源于stack exchange,提问作者Ralf de Kleine

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:29:58