DownloadPipelineArtifact@2 - 下載管線成品 v2 工作

使用此工作可從此管線的先前階段,或從另一個管線下載管線成品。

注意

如需詳細資訊,包括 Azure CLI 命令,請參閱 下載成品

使用此工作可從此管線的先前階段,或從另一個管線下載管線成品。

重要

只有Azure DevOps Services才支援這項工作。 如果您在Azure DevOps Server上使用,如果您使用 Azure DevOps Server 或 TFS 2018,則會收到類似 Pipeline Artifact Task is not supported in on-premises. Please use Build Artifact Task instead. 使用下載組建成品的錯誤訊息。

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).

輸入

buildType - 下載所產生的成品
輸入別名: sourcestring. 必要。 允許的值: current (目前執行) , specific (特定執行) 。 預設值:current

下載目前管線執行或從特定管線執行所產生的成品。


project - 專案
string. 當 source == specific 時為必要。

指定要從中下載管線成品的專案名稱或 GUID。


definition - 建置管線
輸入別名: pipelinestring. 當 source == specific 時為必要。

管線的定義識別碼。 在執行中的管線中, definitionId 可以在 System.DefinitionId 變數中找到。 definitionId您也可以從 Azure DevOps 入口網站中管線概觀頁面上的 URL 擷取 。 在下列 URL 範例中 definitionId ,是 78: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build?definitionId=78&_a=summary 。 若要從特定管線定義下載成品,請從該管線擷取 definitionId ,並將其指定為 pipeline 參數。


specificBuildWithTriggering - 適當時,請從觸發組建下載成品。
輸入別名: preferTriggeringPipelineboolean. 選擇性。 使用 時 source == specific 。 預設值:false

如果已核取,工作會從觸發組建下載成品。 如果沒有從指定的管線觸發組建,工作會從下列選項中指定的組建下載成品。


buildVersionToDownload - 要下載的組建版本
輸入別名: runVersionstring. 當 source == specific 時為必要。 允許的值: latestlatestFromBranch 從特定分支 (最新,以及指定的組建標籤) , specific (特定版本) 。 預設值:latest

指定要下載的組建版本。


branchName - 分支名稱
輸入別名: runBranchstring. 當 source == specific && runVersion == latestFromBranch 時為必要。 預設值:refs/heads/master

指定分支/ref 名稱上的篩選。 例如:refs/heads/develop


pipelineId - 建立
輸入別名: runId | buildIdstring. 當 source == specific && runVersion == specific 時為必要。

要從中下載成品之管線執行的識別碼。 在執行中的管線中, buildId 可以在 Build.BuildId 變數中找到 。 buildId您也可以從 Azure DevOps 入口網站中管線執行摘要頁面上的 URL 擷取 。 在下列 URL 範例中 buildId ,是 1088: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build/results?buildId=1088&view=results 。 若要從特定管線執行下載成品,請從該執行中擷取 buildId ,並將其指定為 buildId 參數。


tags - 建置標籤
string. 選擇性。 使用 時 source == specific && runVersion != specific

工作用來傳回標記組建的逗號分隔標籤清單。 未標記的組建不會傳回。


allowPartiallySucceededBuilds - 從部分成功組建下載成品。
boolean. 選擇性。 使用 時 source == specific && runVersion != specific 。 預設值:false

指定組建工作是否會下載成品,而建置是否成功或部分成功。


allowFailedBuilds - 從失敗的組建下載成品。
boolean. 選擇性。 使用 時 source == specific && runVersion != specific 。 預設值:false

如果已核取,則建置工作會下載組建成功或失敗的成品。


artifactName - 成品名稱
輸入別名: artifactstring.

指定要下載的成品名稱。 如果值保留空白,工作會下載與管線執行相關聯的所有成品。


itemPattern - 比對模式
輸入別名: patternsstring. 預設值:**

限制下載之檔案的檔案比對模式。 此值可以是一或多個以新行分隔的檔案比對模式。 深入瞭解 檔案比對模式


targetPath - 目的地目錄
輸入別名: path | downloadPathstring. 必要。 預設值:$(Pipeline.Workspace)

指定將下載成品之代理程式電腦上的相對路徑或絕對路徑。 如果 (套用多重下載選項,) 保留空的成品名稱,則會為每個下載建立子目錄。 深入瞭解 Azure Pipelines 中的成品


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制選項和一般工作屬性

輸出變數

此工作會定義下列 輸出變數,您可以在下游步驟、作業和階段中使用。

BuildNumber
儲存管線成品來源的組建編號。

由於回溯相容性,此變數會傳回 BuildId

深入瞭解 組建變數

此工作會定義下列 輸出變數,您可以在下游步驟、作業和階段中使用。

BuildNumber
儲存管線成品來源的組建編號。

備註

重要

只有Azure DevOps Services才支援這項工作。 如果您在Azure DevOps Server上使用,如果您使用 Azure DevOps Server 或 TFS 2018,則會收到類似 Pipeline Artifact Task is not supported in on-premises. Please use Build Artifact Task instead. 使用下載組建成品的錯誤訊息。

使用此工作可從此管線的先前階段,或從另一個管線下載管線成品。 根據預設,成品會下載至 $(Pipeline.Workspace) 。 如果您未指定成品名稱,將會為每個下載的成品建立子目錄。 您可以使用 檔案比對模式 來限制您想要下載的檔案。

發佈下載關鍵字是發佈下載管線成品的工作快捷方式。

如何找到想要從中下載成品的管線識別碼?

尋找特定管線定義的 definitionId

在執行中的管線中, definitionId 可以在 System.DefinitionId 變數中找到 。 definitionId您也可以從 Azure DevOps 入口網站中管線概觀頁面上的 URL 擷取 。 在下列 URL 範例中 definitionId ,是 78: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build?definitionId=78&_a=summary 。 若要從特定管線定義下載成品,請從該管線擷取 definitionId ,並將其指定為 pipeline 參數。

尋找特定管線執行的 buildId

要從中下載成品之管線執行的識別碼。 在執行中的管線中, buildId 可以在 Build.BuildId 變數中找到 。 buildId您也可以從 Azure DevOps 入口網站中管線執行摘要頁面上的 URL 擷取 。 在下列 URL 範例中 buildId ,是 1088: https://dev.azure.com/fabrikam-inc/FabrikamFiber/_build/results?buildId=1088&view=results 。 若要從特定管線執行下載成品,請從該執行中擷取 buildId ,並將其指定為 buildId 參數。

範例

下載特定成品

# 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 pipeline.
- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'specific'
    project: 'FabrikamFiber'
    definition: 12
    buildVersionToDownload: 'latest'

從特定分支下載成品

# 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 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

規格需求

需求 描述
管線類型 YAML、傳統組建、傳統版本
在 上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任何
可設定變數 任何
代理程式版本 2.164.1 或更新版本
工作類別 公用程式