有没有办法使用 azure CLI 获取特定任务 ID 的标签?

is there a way to get tags for a specific task ID using the azure CLI?

我刚刚拿到了Azure基础证书,我正在练习以提高我的知识。我想弄清楚的是我的构建机器根据与该提交关联的任务 运行 不同任务的方法。所以基本上程序员会在提交消息中包含任务 ID,然后我需要在 Azure DevOps 任务跟踪器 (vsts) 中查找与该任务 ID 相关的标签,并根据 tag/s 运行 对我的詹金斯管道进行不同的测试。我一直在检查 azure documentation 但我找不到任何命令来获取任务的标签

从提交消息中获取任务工作项的 ID 后,您可以运行 命令“az boards work-item show”获取此任务工作项的详细信息。

az boards work-item show --id {work item id}

此命令的响应主体是 JSON 类型的上下文。从响应正文中的 属性 'System.Tags' 中,您可以获取尚未添加到此任务工作项的标签。

您还 运行 API “Work Items - Get Work Item” 以获得相同的 JSON 类型响应正文。

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.1-preview.3

如果您在响应正文中没有看到 属性 'System.Tags',请添加参数 'expand' 并将其值设置为 'all' 以便响应正文可以显示工作项的完整详细信息。

  • 使用 Azure CLI

    az boards work-item show --id {work item id} --expand all
    
  • 使用API

    GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?$expand=all&api-version=6.1-preview.3
    

默认情况下,参数'expand'设置为'none',这可能使某些属性不显示在响应正文中。