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
1 Answer
Reset to default 0The 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: