A common use of multi-stage pipelines it to separate the build stage and the deployment stage. To make this possible, the build stage often publishes one or more pipeline artifacts. This was discussed in the previous chapter.
All the artifacts that were published in a previous stage of the current pipeline can be downloaded using a download task:
steps:
- download: current
artifact: artifactName
It is also possible to download artifacts from other pipelines. To do this, the current constant has to be replaced with the name of that pipeline. Pipeline artifacts are downloaded to the $(Pipeline.Workspace) directory.
Publishing and downloading artifacts within a pipeline ensures that the code that is built in the first stage is also the code that is deployed in the second stage – even if the stages run days apart. In essence, each pipeline run builds a local stage of all the artifacts associated with that specific run.