Skip to content
Latchkey

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: dist

Gotchas

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →