您可以在不下载工件的情况下读取工件的属性吗?

Can you read the properties of an artifact without downloading it?

我正在开发一个发布管道,我想在其中对给定的工件进行一些分析。以后我不会将该工件本身用于任何用途,我只对读取某些属性(如版本号)感兴趣。因此,我认为没有必要下载我不会做任何更改或发布的工件。从我的角度来看,最节省时间和资源的方法是不必下载工件,但我不确定这是否可行。或者是否有解决方法,您可以在哪里下载该工件的“精简版”?我打算为此使用一个任务。

如果您想获取 build/pipeline 工件的元数据,则无法执行此操作,因为没有这样的东西。您可以调用此端点:

https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/6179/artifacts?api-version=6.1-preview.5

但你只会得到这样的东西:

{
    "count": 1,
    "value": [
        {
            "id": 1095,
            "name": "drop",
            "source": "12f1170f-54f2-53f3-20dd-22fc7dff55f9",
            "resource": {
                "type": "Container",
                "data": "#/6799617/drop",
                "properties": {
                    "localpath": "D:\a\1\a",
                    "artifactsize": "1330651"
                },
                "url": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/6179/artifacts?artifactName=drop&api-version=6.1-preview.5",
                "downloadUrl": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/6179/artifacts?artifactName=drop&api-version=6.1-preview.5&%24format=zip"
            }
        }
    ]
}

如果你想在 Azure Artifact 中获取你的包的详细信息,你可以在 REST API. For instance: Artifact Details - Get Package Version

中选择一些选项