I have two azure devops pipelines as follows:
This creates a folder named 'AncientArtifact-1.2.0.12345' (first pipeline most recent BuildId=12345) inside a $(CustomDestinationFolder) in the second pipeline build.
I want to rename the above folder to something like 'ancient' and move it to another directory within the second pipeline build to be included in the second pipeline artifact.
I have tried using the copy files task but the problem is I don't know the name of the downloaded artifact folder thus I can only specify its parent $(CustomDestinationFolder) as source folder and so my destination folder will look something like $(destinationFolder)\AncientArtifact-1.2.0.12345*. Using the flattenFolders option will flatten everything and that is not what I want.
Some approaches come to mind:
Is there a better way to handle this?
Different with Eric, here I just follow your idea1 by keeping $(Build.buildId)
specified in artifact name.
If you set the system.debug
of pipeline2
as true
, you will see that the task DownloadBuildArtifacts
itself generate one environment variable based on different builds used: BuildNumber
Just make use of it, set reference name
of DownloadBuildArtifacts
task: ref
.
Then, you can call this variable to get buildid
value during next steps: $(ref.BuildNumber)
.
Meanwhile, you can use copy files task by keeping the artifact name contain the $(Build.BuildId)
value in it.