Rediger

Del via


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.

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

Important

This task is supported on Azure DevOps Services only. If you use it on Azure DevOps Server, you'll receive an error message similar to Pipeline Artifact Task is not supported in on-premises. Please use Build Artifact Task instead. Use Download Build Artifacts if you're using Azure DevOps Server or TFS 2018.

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. In a running pipeline the definitionId can be found in the System.DefinitionId variable. The definitionId can also be retrieved from the URL on the pipeline overview page in the Azure DevOps portal. In the following URL example, the definitionId is 78: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build?definitionId=78&_a=summary. To download artifacts from a specific pipeline definition, capture the definitionId from that pipeline, and specify it as the pipeline parameter.


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 identifier of the pipeline run from which to download the artifacts. In a running pipeline the buildId can be found in the Build.BuildId variable. The buildId can also be retrieved from the URL on the pipeline run summary page in the Azure DevOps portal. In the following URL example, the buildId is 1088: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build/results?buildId=1088&view=results. To download artifacts from a specific pipeline run, capture the buildId from that run, and specify it as the buildId parameter.


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

Important

This task is supported on Azure DevOps Services only. If you use it on Azure DevOps Server, you'll receive an error message similar to Pipeline Artifact Task is not supported in on-premises. Please use Build Artifact Task instead. Use Download Build Artifacts if you're using Azure DevOps Server or TFS 2018.

Use this task to download pipeline artifacts from earlier stages in this pipeline, or from another pipeline. By default, artifacts are downloaded to $(Pipeline.Workspace). If you don't specify an artifact name, a subdirectory will be created for each downloaded artifact. You can use file matching patterns to limit the files you want to download.

The publish and download keywords are tasks shortcuts to publish and download your pipeline artifacts.

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

To find the definitionId for a specific pipeline definition

In a running pipeline, the definitionId can be found in the System.DefinitionId variable. The definitionId can also be retrieved from the URL on the pipeline overview page in the Azure DevOps portal. In the following URL example, the definitionId is 78: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build?definitionId=78&_a=summary. To download artifacts from a specific pipeline definition, capture the definitionId from that pipeline, and specify it as the pipeline parameter.

To find the buildId for a specific pipeline run

The identifier of the pipeline run from which to download the artifacts. In a running pipeline the buildId can be found in the Build.BuildId variable. The buildId can also be retrieved from the URL on the pipeline run summary page in the Azure DevOps portal. In the following URL example, the buildId is 1088: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build/results?buildId=1088&view=results. To download artifacts from a specific pipeline run, capture the buildId from that run, and specify it as the buildId parameter.

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