How to Publish and Download Pipeline Artifacts in Azure Pipelines
Pipeline artifacts persist build output and hand it to a later job or stage that needs the files.
Publish files with PublishPipelineArtifact@1, then retrieve them in a downstream job with DownloadPipelineArtifact@2, gated on dependsOn.
Publish then download
Name the artifact on publish; download it by the same name in a dependent job.
azure-pipelines.yml
stages:
- stage: Build
jobs:
- job: B
steps:
- script: npm run build
- task: PublishPipelineArtifact@1
inputs:
targetPath: dist
artifact: web-dist
- stage: Deploy
dependsOn: Build
jobs:
- job: D
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: web-dist
path: distGotchas
- Pipeline artifacts (newer, faster) differ from the legacy build artifacts - prefer the Pipeline variants.
- Without
dependsOn, the download may run before the upstream publish completes. - Artifact names must be unique within a run; suffix with the job name in a matrix.
Related guides
How to Cache Build Dependencies in Azure PipelinesCache npm, pip, or other dependencies in Azure Pipelines with the Cache@2 task using a lockfile-hashed key an…
How to Set Output Variables Between Jobs in Azure PipelinesPass a value from one Azure Pipelines job to another with an isOutput logging command and dependencies.<job>.…