Download Pipeline Artifact task

Use this task in a build or release pipeline to download pipeline artifacts from earlier stages in this pipeline, or from another pipeline.

YAML snippet

# Download pipeline artifact
# Download build and pipeline artifacts
- task: DownloadPipelineArtifact@2
  inputs:
    #buildType: 'current' # Options: current, specific
    #project: # Required when buildType == Specific
    #definition: # Required when buildType == Specific
    #specificBuildWithTriggering: false # Optional
    #buildVersionToDownload: 'latest' # Required when buildType == Specific# Options: latest, latestFromBranch, specific
    #branchName: 'refs/heads/master' # Required when buildType == Specific && RunVersion == LatestFromBranch
    #pipelineId: # Required when buildType == Specific && RunVersion == Specific
    #tags: # Optional
    #artifactName: # Optional
    #itemPattern: '**' # Optional
    #targetPath: '$(Pipeline.Workspace)' 

Arguments

Argument Description
source
Download artifacts produced by
Download artifacts produced by the current pipeline run, or from a specific pipeline run.
Options: current, specific
preferTriggeringPipeline
When appropriate, download artifacts from the triggering build
A boolean specifying whether to download artifacts from a triggering build.
tags
Build Tags
A coma-delimited list of tags. Only builds with these tags will be returned.
artifact
Artifact Name
The name of the artifact to download. If left empty, all artifacts associated to the pipeline run will be downloaded.
patterns
Matching Patterns
One or more file matching patterns (new line delimited) that limit which files get downloaded. More Information on file matching patterns
path
Destination Directory
Directory to download the artifact files. Can be relative to the pipeline workspace directory or absolute. If multi-download option is applied (by leaving an empty artifact name), a sub-directory will be created for each. See Artifacts in Azure Pipelines.
project
Project
The project GUID from which to download the pipeline artifacts.
pipeline
Build Pipeline
The definition ID of the build pipeline.
runVersion
Build version to download
Specifies which build version to download. Options: latest, latestFromBranch, specific
runBranch
Branch Name
Specify to filter on branch/ref name, for example: refs/heads/develop.
runId
Build
The build from which to download the artifacts. For example: 1764
Control options

Examples

Download a specific artifact

# Download an artifact named 'WebApp' to 'bin' in $(Build.SourcesDirectory)
- task: DownloadPipelineArtifact@2
  inputs:
    artifact: 'WebApp'
    path: $(Build.SourcesDirectory)/bin

Download artifacts from a specific project/pipeline

# Download artifacts from a specific pipeline.
- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    project: 'FabrikamFiber'
    pipeline: 12
    runVersion: 'latest'

Download artifacts from a specific branch

# Download artifacts from a specific branch with a tag
- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    project: 'FabrikamFiber'
    pipeline: 12
    runVersion: 'latestFromBranch'
    runBranch: 'refs/heads/master'
    tags: 'testTag'

Download an artifact from a specific build run

# Download an artifact named 'WebApp' from a specific build run to 'bin' in $(Build.SourcesDirectory)
- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    artifact: 'WebApp'
    path: $(Build.SourcesDirectory)/bin
    project: 'FabrikamFiber'
    pipeline: 12
    runVersion: 'specific'
    runId: 2995

Q&A

How can I find the ID of the Pipeline I want to download an artifact from?

You can find the ID of the pipeline in the 'Pipeline variables'. The pipeline ID is the system.definitionId variable.

Open source

This task is open source on GitHub. Feedback and contributions are welcome.