DownloadPipelineArtifact@2 - Download Pipeline Artifacts v2 task

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

Note

For more information, including Azure CLI commands, see downloading artifacts.

Syntax

# Download Pipeline Artifacts v2
# Download build and pipeline artifacts.
- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'current' # 'current' | 'specific'. Alias: source. Required. Download artifacts produced by. Default: current.
    #project: # string. Required when source == specific. Project. 
    #definition: # string. Alias: pipeline. Required when source == specific. Build pipeline. 
    #specificBuildWithTriggering: false # boolean. Alias: preferTriggeringPipeline. Optional. Use when source == specific. When appropriate, download artifacts from the triggering build. Default: false.
    #buildVersionToDownload: 'latest' # 'latest' | 'latestFromBranch' | 'specific'. Alias: runVersion. Required when source == specific. Build version to download. Default: latest.
    #branchName: 'refs/heads/master' # string. Alias: runBranch. Required when source == specific && runVersion == latestFromBranch. Branch name. Default: refs/heads/master.
    #pipelineId: # string. Alias: runId | buildId. Required when source == specific && runVersion == specific. Build. 
    #tags: # string. Optional. Use when source == specific && runVersion != specific. Build Tags. 
    #allowPartiallySucceededBuilds: false # boolean. Optional. Use when source == specific && runVersion != specific. Download artifacts from partially succeeded builds. Default: false.
    #allowFailedBuilds: false # boolean. Optional. Use when source == specific && runVersion != specific. Download artifacts from failed builds. Default: false.
    #artifactName: # string. Alias: artifact. Artifact name. 
    #itemPattern: '**' # string. Alias: patterns. Matching patterns. Default: **.
    targetPath: '$(Pipeline.Workspace)' # string. Alias: path | downloadPath. Required. Destination directory. Default: $(Pipeline.Workspace).

Inputs

buildType - Download artifacts produced by
Input alias: source. string. Required. Allowed values: current (Current run), specific (Specific run). Default value: current.

Downloads artifacts produced by the current pipeline run or from a specific pipeline run.


project - Project
string. Required when source == specific.

Specifies the project name or GUID from which to download the pipeline artifacts.


definition - Build pipeline
Input alias: pipeline. string. Required when source == specific.

The definition ID of the pipeline.


specificBuildWithTriggering - When appropriate, download artifacts from the triggering build.
Input alias: preferTriggeringPipeline. boolean. Optional. Use when source == specific. Default value: false.

If checked, the task downloads artifacts from the triggering build. If there is no triggering build from the specified pipeline, the task downloads artifacts from the build specified in the options below.


buildVersionToDownload - Build version to download
Input alias: runVersion. string. Required when source == specific. Allowed values: latest, latestFromBranch (Latest from specific branch and specified Build Tags), specific (Specific version). Default value: latest.

Specifies the build version to download.


branchName - Branch name
Input alias: runBranch. string. Required when source == specific && runVersion == latestFromBranch. Default value: refs/heads/master.

Specifies the filter on the branch/ref name. For example: refs/heads/develop.


pipelineId - Build
Input alias: runId | buildId. string. Required when source == specific && runVersion == specific.

The build from which to download the artifacts. For example: 1764.


tags - Build Tags
string. Optional. Use when source == specific && runVersion != specific.

The comma-delimited list of tags that the task uses to return tagged builds. Untagged builds are not returned.


allowPartiallySucceededBuilds - Download artifacts from partially succeeded builds.
boolean. Optional. Use when source == specific && runVersion != specific. Default value: false.

Specifies if the build task downloads artifacts whether the build succeeds or partially succeeds.


allowFailedBuilds - Download artifacts from failed builds.
boolean. Optional. Use when source == specific && runVersion != specific. Default value: false.

If checked, the build task downloads artifacts whether the build succeeds or fails.


artifactName - Artifact name
Input alias: artifact. string.

Specifies the name of the artifact to download. If the value is left empty, the task downloads all artifacts associated with the pipeline run.


itemPattern - Matching patterns
Input alias: patterns. string. Default value: **.

The file matching patterns that limit downloaded files. The value can be one or more file matching patterns that are new line delimited. Learn more about file matching patterns.


targetPath - Destination directory
Input alias: path | downloadPath. string. Required. Default value: $(Pipeline.Workspace).

Specifies either a relative or absolute path on the agent machine where the artifacts will download. If the multi-download option is applied (by leaving an empty artifact name), a sub-directory will be created for each download. Learn more about Artifacts in Azure Pipelines.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

This task defines the following output variables, which you can consume in downstream steps, jobs, and stages.

BuildNumber
Stores the build number of the pipeline artifact source.

Due to backwards compatibility, this variable returns BuildId.

Learn more about build variables.

This task defines the following output variables, which you can consume in downstream steps, jobs, and stages.

BuildNumber
Stores the build number of the pipeline artifact source.

Remarks

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

Note

For more information, including Azure CLI commands, see downloading artifacts.

The publish and download keywords are shortcuts for the Publish Pipeline Artifact task. You can use them in your pipeline to publish and download artifacts. For more information, see Publish and Download in the YAML schema.

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. You can also find the ID in the URL path.

Examples

Download a specific artifact

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

Download artifacts from a specific project/pipeline

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

Download artifacts from a specific branch

# Download artifacts from a specific branch with a tag
- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'specific'
    project: 'FabrikamFiber'
    definition: 12
    buildVersionToDownload: 'latestFromBranch'
    branchName: '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:
    buildType: 'specific'
    artifactName: 'WebApp'
    targetPath: $(Build.SourcesDirectory)/bin
    project: 'FabrikamFiber'
    definition: 12
    buildVersionToDownload: 'specific'
    pipelineId: 40

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.164.1 or greater
Task category Utility