I have GUI-based release pipeline that deploys artifact produced from build pipeline. I can chose which version of the artifact I need to deploy.
How I can achieve the same using YAML pipelines?
You can use the Download Pipeline Artifacts task with the runId
input:
# Download an artifact named 'WebApp' from a specific build run to 'bin' in $(Build.SourcesDirectory)
- task: DownloadPipelineArtifact@2
inputs:
source: 'specific'
artifact: 'WebApp'
path: $(Build.SourcesDirectory)/bin
project: 'FabrikamFiber'
pipeline: 12
runVersion: 'specific'
runId: 40
Here I agree with @Shayki, I know this is very convenient to choose corresponding artifact based on actual demands, but what you want does not supported in YAML until now.
Because, what the trouble is, the time it configured is after the builds execute finished while you using release with classic UI like the above pic shown. At this time, the system could detect and display the artifacts history.
But, when you using multi-stage
to configure the pipeline, the build and release process are combined together. We are developing to enrich the functionality of YAML pipeline, but until now, we haven't expand the feature like collect all artifacts info from builds history and show them in YAML configuration panel.
So, hard code the build number is necessary if you want to achieve the similar feature with select artifacts now.
If you don't want hard code the runid
in YAML definition, you can consider to pass queue variable
as a work around.
For example:
- task: DownloadPipelineArtifact@2
inputs:
source: 'specific'
artifact: 'drop'
path: $(Build.SourcesDirectory)/bin
project: 'AndroidBuild'
pipeline: 12
runVersion: 'specific'
runId: $(buildid)
In above definition, buildid
is the variable, and you can configure its value at queue time:
This do not need you to do any modification to the pipeline when you want to choosing another artifacts, just pass the value at queue time. But, as you see, hard code it still needed.
It would be a great feature if we can select instead of remember and hard code the value. You could raise your idea to our official forum, our Product team would review it regularly and would consider to take it into our develop Roadmap.