Home > Software design >  How to get date of tag from Azure Devops Cli
How to get date of tag from Azure Devops Cli

Time:06-14

I'm using the Azure devops cli to get a list of the tags for a particular repo. Documented here: https://docs.microsoft.com/en-us/cli/azure/repos?view=azure-cli-latest. For example

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

The result looks something like this

[
  {
    "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>"
  }
]

There does not seem to be a date available. I get the object id and if this was local, I could do git show <objectid>, but there doesn't seem to be anything in the api to get the date or any other specific information, based on an object id

Just to clarify, in my case, the date of tag creation and the date of commit is typically the same so either would be fine

CodePudding user response:

I am afraid that Azure DevOps CLI doesn't support to get the specific information based on Object Id of the Repo tag.

I suggest that you can use Rest API to achieve the requirement: Annotated Tags - Get

Rest API:

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

Result sample:

{
  "name": "refs/tags/v0.1-beta2",
  "objectId": "69080710948ac8ba63e44eca2daf0b30f38c428d",
  "taggedObject": {
    "objectId": "c60be62ebf0e86b5aa01dbb98657b4b7e5905234",
    "objectType": "commit"
  },
  "taggedBy": {
    "name": "Norman Paulk",
    "email": "[email protected]",
    "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"
}

You can also use Rest API to list tags of the repo: Refs - List

  • Related