【问题标题】:Azure DevOps Field Values from list of builds构建列表中的 Azure DevOps 字段值
【发布时间】:2020-01-24 06:32:46
【问题描述】:

我们在公司内部使用 Azure DevOps 2019,我想在我们的 Bug 工作项中创建一个选项框字段,我希望它是一个组合框,其中的值是从所有在项目下构建定义。

通过检查系统的文档,我没有找到任何选项来执行此操作,以及是否最好通过 API 查询系统或查询数据库。

【问题讨论】:

  • 您使用继承流程还是托管 XML 流程?
  • 托管 XML 进程

标签: tfs azure-devops tfs-workitem azure-devops-server-2019 azure-devops-server


【解决方案1】:

我认为没有这样的内置功能。

你可以做的是创建一个字符串字段,从 gloabllist 中获取值,在 globallist 中第一次创建一个带有项目名称的 globallist,例如:

<GLOBALLIST name="MyProject-builds">
</GLOBALLIST>

现在您可以使用 PowerShell 获取此项目的构建定义,并使用值更新此全局列表:

Param(
   [string]$collection = "http://tfs-server:8080/tfs/collection",
   [string]$project = "MyProject",
   [string]$filePath  = "C:\Globallist.xml"
)

$url = "$collection/$project/_apis/build/definitions?api-version=4.0"
$builds = (Invoke-RestMethod -Uri $url -Method Get -UseDefaultCredentials -ContentType application/json).value.name

witadmin exportgloballist /collection:$collection /f:$filePath
[xml]$gloabllist = Get-Content $filePath
$gloabllist.GLOBALLISTS.GLOBALLIST.Where({ $_.name -eq "$project-builds" }).LISTITEM | %{ $_.ParentNode.RemoveChild($_) | Out-Null }
$node = $gloabllist.GLOBALLISTS.GLOBALLIST.Where({ $_.name -eq "$project-builds" })
$builds.ForEach({

    $child = $gloabllist.CreateElement("LISTITEM")
    $att = $gloabllist.CreateAttribute("value")
    $child.Attributes.Append($att)
    $child.value = "$_"
    $node.AppendChild($child)
})

$gloabllist.Save($filePath)
witadmin importgloballist /collection:$collection /f:$filePath

您可以设置每天调整此脚本的计划构建以始终更新。

您还可以改进脚本以获取所有项目、迭代它们、获取构建定义名称并更新 globallist 文件。

【讨论】:

    猜你喜欢
    • 2020-07-04
    • 2020-07-22
    • 1970-01-01
    • 2021-01-21
    • 1970-01-01
    • 2021-11-18
    • 2021-12-09
    • 2021-01-03
    • 2019-04-14
    相关资源
    最近更新 更多