Download Pipeline Artifacts task

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

YAML snippet

# Download pipeline artifacts
# Download build and pipeline artifacts
- task: DownloadPipelineArtifact@2
  inputs:
    #source: 'current' # Options: current, specific
    #project: # Required when source == Specific
    #pipeline: # Required when source == Specific
    #preferTriggeringPipeline: false # Optional
    #runVersion: 'latest' # Required when source == Specific# Options: latest, latestFromBranch, specific
    #runBranch: 'refs/heads/master' # Required when source == Specific && RunVersion == LatestFromBranch
    #runId: # Required when source == Specific && RunVersion == Specific
    #tags: # Optional
    #artifact: # Optional
    #patterns: '**' # Optional
    #path: '$(Pipeline.Workspace)' 

Arguments

Argument Description
source
Download artifacts produced by
(Required) Download artifacts produced by the current pipeline run, or from a specific pipeline run.
Options: current, specific
Default value: current
Argument aliases: buildType
project
Project
(Required) The project GUID from which to download the pipeline artifacts.
pipeline
Build Pipeline
(Required) The definition ID of the build pipeline.
Argument aliases: definition
preferTriggeringPipeline
When appropriate, download artifacts from the triggering build
(Optional) A boolean specifying whether to download artifacts from a triggering build.
Default value: false
Argument aliases: specificBuildWithTriggering
runVersion
Build version to download
(Required) Specifies which build version to download. Options: latest, latestFromBranch, specific
Default value: latest
Argument aliases: buildVersionToDownload
runBranch
Branch Name
Specify to filter on branch/ref name. For example: refs/heads/develop.
Default value: refs/heads/master
Argument aliases: branchName
runId
Build
(Required) The build from which to download the artifacts. For example: 1764
Argument aliases: pipelineId, buildId
tags
Build Tags
(Optional) A comma-delimited list of tags. Only builds with these tags will be returned.
allowPartiallySucceededBuilds
Download artifacts from partially succeeded builds
(Optional) If checked, this build task will try to download artifacts whether the build is succeeded or partially succeeded
Default value: false
allowFailedBuilds
Download artifacts from failed builds
(Optional) If checked, this build task will try to download artifacts whether the build is succeeded or failed
Default value: false
artifact
Artifact Name
(Optional) The name of the artifact to download. If left empty, all artifacts associated to the pipeline run will be downloaded.
Argument aliases: artifactName
patterns
Matching Patterns
(Optional) One or more file matching patterns (new line delimited) that limit which files get downloaded. More Information on file matching patterns
Default value: **
Argument aliases: itemPattern
path
Destination Directory
(Required) 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.
Default value: $(Pipeline.Workspace)
Argument aliases: targetPath, downloadPath

Note

If you want to consume artifacts as part of CI/CD flow, refer to the download shortcut here.

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

FAQ

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.