TL;DR: How to get all the artifact names in deploy pipeline?
Hi,
I have multiple branches, and a single generic build pipeline to build their artifacts
artifact name example: TestProject_Feature1Branch_BuildNumber70_Date20240725
I’d like to create a generic deploy pipeline. How can I easily pick which artifact to deploy?
In the deploy pipeline, I could parameterize the artifact name but having to dig into each build artifact to copy & paste, or manually typing in the name seems to be annoying and error-prone. Ideally, I’d like a dropdown with all the artifact names from the build pipeline.
Thank you!
2
Answers
You can get the all the artifact names of a build pipeline in a script using the REST API.
First, get the successful runs’ ids of the pipeline with Builds – List. Then, get the artifact names for the build runs with Artifacts – List.
Here is the sample PowerShell script:
After running the script, you can copy the output of the script and use it as parameters values in the deploy pipeline YAML.
Based on your description, I suggest that you can use the Pipeline resource in deploy Pipeline.
Here is an example:
When you run the Pipeline, you can click the Resources tab and select the target artifacts in target Pipeline Run.
For example:
Note: By default, it will show the Build Number, branch, date information. You can select the artifacts based on the information. Or you can custom the Build number variable based on the artifact name.
For more detailed info, you can refer to this doc: Pipelines resource definition