最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to upload a zip file to an Azure DevOps pipeline run using Azure DevOps API - Stack Overflow

programmeradmin3浏览0评论

I have a zip file which is created by one of my java program , I need to upload this as an artifact to an Azure DevOps Pipeline, I get the BuildId as a parameter to my program when I check the API docs I see this , But it seems it provides location of a URL , But I need to upload it from my local temp files. Is there a way to do this?

I have checked ChatGPT and it provides something like below:

curl -u "PAT:" \
     -H "Content-Type: application/octet-stream" \
     --data-binary @your-file.zip \
     -X PUT "/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName=my-zip-artifact&api-version=7.1-preview.5"

But documentation does not seem to contain this. Any one has done this before?

I have a zip file which is created by one of my java program , I need to upload this as an artifact to an Azure DevOps Pipeline, I get the BuildId as a parameter to my program when I check the API docs I see this , But it seems it provides location of a URL , But I need to upload it from my local temp files. Is there a way to do this?

I have checked ChatGPT and it provides something like below:

curl -u "PAT:" \
     -H "Content-Type: application/octet-stream" \
     --data-binary @your-file.zip \
     -X PUT "https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName=my-zip-artifact&api-version=7.1-preview.5"

But documentation does not seem to contain this. Any one has done this before?

Share Improve this question asked Jan 20 at 15:04 jereesh thomasjereesh thomas 1712 silver badges15 bronze badges 1
  • checked this? stackoverflow.com/questions/12667797/… – Rafael Commented Jan 20 at 15:07
Add a comment  | 

1 Answer 1

Reset to default 0

The REST API Artifacts - Create is used to associate an artifact with a build. Which means that it needs an existed pipeline/build artifact instead of creating a new artifact for the build.

To upload a zip file to build artifact, it's suggested that you could use Azure DevOps CLI az pipelines runs artifact upload.

az pipelines runs artifact upload --artifact-name {your artifact name} --path "{path to your zip file}" --run-id {your target build id} --org "https://dev.azure.com/{org name}" --project "{your project name}"

For example, az pipelines runs artifact upload --artifact-name myartifact --path "myzip.zip" --run-id 3252 --org "https://dev.azure.com/***" --project "***"

Result:

发布评论

评论列表(0)

  1. 暂无评论