I am using the DownloadPipelineArtifact@2 task and looping over an array of pipelines to download the artifacts for each of them. I would like to use the $(BuildNumber) output of each of these tasks in subsequent tasks.
${{ each p in pipelines }}:
- task: DownloadPipelineArtifact@2
displayName: 'Download ${{ p.alias }} Artifact - ${{ p.artifact }}'
name: 'Download_${{ p.alias }}'
inputs:
buildType: specific
project: $(System.TeamProjectId)
pipeline: ${{ p.id }}
preferTriggeringPipeline: false
runVersion: latestFromBranch
runBranch: 'refs/heads/${{ p.branch }}'
artifact: ${{ p.artifact }}
patterns: ${{ p.patterns }}
targetPath: '$(Pipeline.Workspace)/artifacts/${{ p.alias }}/${{ p.artifact }}'
Unfortunately, I am unable to do so as I would need to refer to the task by it's name and I am not able to assign dynamic names to the tasks. I get an error saying
Valid names may only contain alphanumeric characters and '_' and may not start with a number.
I tried using runtime variables, expressions and a counter for the name but all fail with the same error. I am assuming here the name field is not dynamically assignable.
All works well without the name field. But from what I understand I would need the name of the task to refer to it and extract it's output. Something like:
{{ taskName.BuildNumber }}
If anyone knows of any way in which I can assign the name dynamically or through which I can extract the $(BuildNumber) for each task in the loop, please let me know. Thanks!