How to get the download url of the artifact in Visual Studio Team Services?

徘徊边缘 提交于 2020-01-13 19:54:06

问题


I'm developing a plugin in Visual Studio Code that allows downloading of artifacts from VSTS (Visual Studio Team Services) but I don't know where to get the URL? How can I get the URL of the download button?


回答1:


You can get the download URL for build artifacts through REST API.

Use the REST API to get build artifacts:

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

You will get the response as below:

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

For the value of downloadUrl (as https://account.visualstudio.com/DefaultCollection/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/build/builds/1581/artifacts?artifactName=drop&%24format=zip in above example) is what you need.



来源:https://stackoverflow.com/questions/46519049/how-to-get-the-download-url-of-the-artifact-in-visual-studio-team-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!