azure - 如何从 Azure Devops Cli 获取标签日期

标签 azure azure-devops

我正在使用 Azure Devops cli 获取特定存储库的标签列表。记录在这里:https://learn.microsoft.com/en-us/cli/azure/repos?view=azure-cli-latest 。例如

az repos ref list -p <project>-r <name of repo> --filter tags

结果看起来像这样

[
  {
    "creator": {
      "descriptor": "aad.ODAzODM5N2YtNWE3Yi03MzBkLThlNTktMzhmMTJlOTU0MTJi",
      "directoryAlias": null,
      "displayName": "<name>",
      "id": "8038397f-5a7b-630d-8e59-38f12e95412b",
      "imageUrl": "https:<redacted>",
      "inactive": null,
      "isAadIdentity": null,
      "isContainer": null,
      "isDeletedInOrigin": null,
      "uniqueName": "<email>",
      "url": "https://<redacted>"
    },
    "isLocked": null,
    "isLockedBy": null,
    "name": "refs/tags/1.0.0-tag-name",
    "objectId": "6ed8645a6e1c6686aa9eead0e60365665d76dfb5",
    "peeledObjectId": null,
    "statuses": null,
    "url": "https://<redacted>"
  }
]

似乎没有可用的日期。我得到了对象 ID,如果这是本地的,我可以这样做 git show <objectid> ,但 api 中似乎没有任何内容可以根据对象 id 获取日期或任何其他特定信息

只是为了澄清,就我而言,标签创建日期和提交日期通常是相同的,所以两者都可以

最佳答案

恐怕Azure DevOps CLI不支持根据Repo标签的Object Id获取具体信息。

我建议您可以使用Rest API来实现需求:Annotated Tags - Get

Rest API:

GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/annotatedtags/{objectId}?api-version=6.0-preview.1

结果示例:

{
  "name": "refs/tags/v0.1-beta2",
  "objectId": "69080710948ac8ba63e44eca2daf0b30f38c428d",
  "taggedObject": {
    "objectId": "c60be62ebf0e86b5aa01dbb98657b4b7e5905234",
    "objectType": "commit"
  },
  "taggedBy": {
    "name": "Norman Paulk",
    "email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f193e3d2d36343e3239363d3a2d6e691f37302b323e3633713c3032" rel="noreferrer noopener nofollow">[email protected]</a>",
    "date": "2017-06-22T04:28:23"
  },
  "message": "First beta release",
  "url": "https://dev.azure.com/fabrikam/c34d5807-1734-4541-ad1c-d16e9ac1faca/_apis/git/repositories/ca93c3a5-87bb-4b5b-a62f-1f971d677c79/annotatedTags/69080710948ac8ba63e44eca2daf0b30f38c428d"
}

您还可以使用Rest API列出存储库的标签:Refs - List

关于azure - 如何从 Azure Devops Cli 获取标签日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72586723/

相关文章:

azure - 身份验证成功后无法在 Azure B2C 中获取用户名

azure-devops - Azure 私有(private)生成代理 : No agent could be found with the following capabilities: npm, azureps

c# - 在一个 C# Azure 函数 session 中处理来自 IoT 中心的多条消息

Azure 容器实例在启动时更改环境变量

azure - 导出 SQL 数据库和 DTU 容量

使用错误版本的包的 Azure DevOps 构建解决方案

git - Azure DevOps - GIT SSH 身份验证 - 远程 : Public key authentication failed

azure - 如何区分azure DevOps构建管道中的分支触发器和计划触发器

c# - 部署在云上时,调用 workItemTrackingHttpClient.CreateWorkItemAsync() 会引发不同的异常

azure - 监视 Azure 数据仓库的正常运行时间和扩展设置