【问题标题】:How do I get more than 50 associated work items for a VSTS build?如何为 VSTS 构建获得超过 50 个相关的工作项?
【发布时间】:2018-07-18 09:39:05
【问题描述】:

我正在尝试使用 VSTS Build (2.0) API 来检索给定构建的关联工作项和更改。 此构建有 100 个与之关联的工作项。 当我使用 get build details/work items REST 方法时,它只会检索 50 个项目。我尝试了以下方法: https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0 // 没有指定最大工作项数 -> 返回 50 https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=100 // 指定最多 100 个项目 -> 它返回 50 https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=0 // 指定 0 的顶部,希望这意味着所有 -> 它返回无 https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=-1 // 指定 -1 的顶部,希望这意味着所有 -> 它返回无 https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=50&$skip=50 // 希望得到接下来的 50 个项目 (51..100) -> 它返回相同的前 50 个

知道如何获得相关工作项的完整列表吗?以及相关的变化?

【问题讨论】:

    标签: tfs azure-devops tfsbuild azure-pipelines


    【解决方案1】:

    目前您无法通过单个 Rest API(https://www.visualstudio.com/en-us/docs/integrate/api/build/builds#work-items) 执行此操作。

    我也有类似的经历,终于发现了这个问题:TFS 2017 Update1: Associated Work Items for a build has a limit of 50 work items。但是,该问题仍然正在考虑中,没有任何更新。

    最终,作为一种解决方法,我获得了单个构建的所有相关变更集,并检索每个变更集的所有相关工作项。

    有效但不高效。

    【讨论】:

    • @Assaf Stone Tomhans 是对的,这是一个已知问题,首次报告于 this thread。您可以尝试从变更集中检索关联的工作项。
    • 感谢汤姆汉和安迪。我找不到用于检索变更集的工作项的 API。你能指点我的 API 吗?
    • @AssafStone 首先从构建中获取变更集 ID。然后使用下面的 REST API:http://your-account.visualstudio.com/DefaultCollection/_apis/tfvc/changesets/{ID}/workItem
    • 这就是我最终为 TFVC 所做的事情。对于 Git,我必须解析实例工作项 ID 的注释。我使用了以下表达式: [Regex]::Matches($change.comment, '#(?\d+)') |选择对象@{名称=“值”;表达式 = {$_.Groups['id'].Value }}
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-24
    • 2018-08-08
    • 2017-04-04
    相关资源
    最近更新 更多