如何在Visual Studio Team Services中获取工件的下载URL?

时间:2017-10-02 03:19:13

标签: azure-devops azure-pipelines-release-pipeline

我正在使用Visual Studio Code开发一个插件,允许从VSTS(Visual Studio Team Services)下载工件,但我不知道从哪里获取URL?如何获取下载按钮的URL?

Click this image link for screenshot

1 个答案:

答案 0 :(得分:6)

您可以通过REST API获取构建工件的下载URL。

使用REST API获取构建工件:

GET https://{account}.visualstudio.com/DefaultCollection/{project}/_apis/build/builds/{buildID}/artifacts?api-version=2.0

您将得到以下答复:

{
    "count": 1,
    "value": [
        {
            "id": 270,
            "name": "drop",
            "resource": {
                "type": "Container",
                "data": "#/514582/drop",
                "properties": {
                    "localpath": "D:\\Agent\\newTFSPCagent\\_work\\3\\a"
                },
                "url": "https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/1581/artifacts?artifactName=drop",
                "downloadUrl": "https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/1581/artifacts?artifactName=drop&%24format=zip"
            }
        }
    ]
}

对于 downloadUrl 的值(在上例中为https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/1581/artifacts?artifactName=drop&%24format=zip)就是您所需要的。