List files of a build artifact - azure-devops

I've seen that in the 5.0 preview of the REST API it seems possible to download a specific file from a build artifact using :
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&fileId={fileId}&fileName={fileName}&api-version=5.0-preview.5
But how to list the files of an artifact ? I don't know what to input for fileId.
My usecase is a folder archived as an artifact during the build. I would like to get download links for each files in the folder.

I found that the API you using is not having complete documentation.
I used below to download specific file from Build artifacts using PowerShell. You could get the container ID from GET build details.
https://$collectionurl/tfs/$teamproject/_apis/resources/Containers/$containerID?itemPath=drop%filename.txt

Related

How to use Bamboo's rest api to download an artifact

I am trying to write a bash script to download an artifact from Bamboo so that it can be used for other operations. I tried following the solution suggested in this post - using bamboo/rest/api/latest/result however I still just get the xml showing the location and the name of the artifact. The artifact itself is not downloaded. Any suggestions on how to go about this?
Below is the api cmd that I am using:
http://myhost.com:8085/bamboo/rest/api/latest/result/{projectKey}-{buildKey} [GET]
After much tweaking I managed to get it to work. I had messed up parsing of the artifact location link extracted from the xml. With the correct link, obtained from the xml, and the right authentication the artifact can be downloaded.

Azure Pipeline artifacts do not show under Storage

I have created a c++ pipeline where the output of the build pipeline is published to drop container. The structure is the following
drop/v1.0.0/Release/MyService.dll
drop/v1.1.0/Release/MyService.dll
drop/v1.1.0/Release/MyService.dll
My engineers will need to view drop folder and according to the version that needs to be manually deployed to a client the will download the dll file.
As far as I understand there is not any way to view them under Artifacts (what a shame). I go to the project settings under Storage but I cannot view them either there. Only place that I am able to find them is under the pipeline run and then I have to find in which version of the pipeline run a specific service version was produced. This is a maze. We have dozens of c++ projects and we have to keep track of which pipeline version run of each project matches the service version.
Is there any way to be able to access them like in a folder structure?
You could use Builds - List via rest API to get all the builds for a pipeline, then use : Artifacts - List rest API to get all the artifacts for a build. It will list all the download URL for artifacts, then you could download them together or choose the one you want to download.
Besides, you could use the publishLocation argument in publish build artifacts task to copy the artifacts to a file share (FilePath). And the file share must be accessible from the agent running the pipeline. In this way you could publish all your artifacts to the file share you want for better management.
In addition, you could also use Universal Package task to publish your artifacts to your feed for better review.

Download lost file from DevOps pipeline Library

I lost a file which is still available in the library inside the DevOps Library.
Is there a way to save a local copy somehow?
It's still possible to use in a pipeline, but I have no idea to get it to my local computer.
You can use the Download Secure File task to download the file in the pipeline and then use Publish Build Artifacts task to publish the file as build artifacts.
See below when downloading using Download Secure File:
Once downloaded, use the name value that is set on the task (or "Reference name" in the classic editor) to reference the path to the secure file on the agent machine. For example, if the task is given the name mySecureFile, its path can be referenced in the pipeline as $(mySecureFile.secureFilePath)
So in the Publish Build Artifacts task set the Path to publish to $(mySecureFile.secureFilePath)
Then you can download the file from the build summary page by clicking the related artifacts. See below:

Getting Azure DevOps Pipeline Artifact output Windows app

Using Azure Devops. Made pipeline using Visual Designer for .Net Desktop application. Trying to get the output (exe). I created a feed in the Artifacts but I don't see a way to specify it in the Pipeline configuration. In the build output for Copy files to $(build.artifactsstagingdirectory) it shows file copied
2019-01-11T01:10:27.4301461Z Copying D:\a\2\s\AzureDevopsSimpleTestApp\bin\Release\AzureDevopsSimpleTestApp.exe to D:\a\2\a\AzureDevopsSimpleTestApp\bin\Release\AzureDevopsSimpleTestApp.exe
2019-01-11T01:10:27.4327361Z Copying D:\a\2\s\AzureDevopsSimpleTestApp\bin\Release\AzureDevopsSimpleTestApp.exe.config to D:\a\2\a\AzureDevopsSimpleTestApp\bin\Release\AzureDevopsSimpleTestApp.exe.config
2019-01-11T01:10:27.4335836Z Copying
D:\a\2\s\AzureDevopsSimpleTestApp\bin\Release\AzureDevopsSimpleTestApp.pdb to
D:\a\2\a\AzureDevopsSimpleTestApp\bin\Release\AzureDevopsSimpleTestApp.pdb
The Publish Artifact step it says file uploaded successfully but where is it?? how can I download it? Thanks!
2019-01-11T01:10:27.8230580Z Uploading 3 files
2019-01-11T01:10:28.1382894Z File upload succeed.
2019-01-11T01:10:28.1382985Z Upload 'D:\a\2\a' to file container: '#/672188/drop'
2019-01-11T01:10:28.1383023Z Associated artifact 2 with build 3
https://imgur.com/a/aBIvlGq
https://i.stack.imgur.com/F56M0.png
https://imgur.com/a/EYbdNpq
how can I download it?
You could download it from Summary tab. For more information, please refer to the screenshot.

Retrieve a downloadTicket for an artifact in VSTS

I am trying to obtain a "publicly accessible" link for the artifact produced during the build process. The API does reference something called a downloadTicket but the API call doesn't seem to return anything related. I understand that the download would need to provide the downloadTicket through a header, but for now, my question is:
What call do I need to make, either through the REST API or within a
build task itself, to get the artifact information, including the
downloadTicket?
Or option two, is there something else I can to avoid uploading
the file to Azure blob, etc.?
Why do you have to retrieve the downloadTicket?
If you just want to download the artifacts you can use the REST API - Artifacts - Get to retrieve the downloadUrl, then you can share and use that URL to download the specific artifact. (Pleas note that the users need the correct permission to view/download build artifacts)
"downloadUrl": "https://{account}.visualstudio.com/{project}/_apis/build/builds/235/artifacts?artifactName=drop&api-version=5.0-preview.3&%24format=zip"
If you want to download the artifacts in build/release process, then you can use Download Build Artifacts task.
For your option 2, you can create a share location then select a file share as the Artifact publish location and specify the share location. Thus the artifacts will be published to the shared folder... You can set the share folder to "publicly accessible"...