PublishPipelineArtifact@1 - 發佈管線成品 v1 工作

使用此工作發佈 (上傳) 檔案或目錄作為目前執行的具名成品。

使用此工作發佈 (上傳) 檔案或目錄作為目前執行的具名成品。

重要

只有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

# Publish Pipeline Artifacts v1
# Publish (upload) a file or directory as a named artifact for the current run.
- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Pipeline.Workspace)' # string. Alias: path. Required. File or directory path. Default: $(Pipeline.Workspace).
    #artifact: # string. Alias: artifactName. Artifact name. 
    publishLocation: 'pipeline' # 'pipeline' | 'filepath'. Alias: artifactType. Required. Artifact publish location. Default: pipeline.
    #fileSharePath: # string. Required when artifactType = filepath. File share path. 
    #parallel: false # boolean. Optional. Use when artifactType = filepath. Parallel copy. Default: false.
    #parallelCount: '8' # string. Optional. Use when artifactType = filepath && parallel = true. Parallel count. Default: 8.
    #properties: # string. Custom properties.
# Publish Pipeline Artifacts v1
# Publish (upload) a file or directory as a named artifact for the current run.
- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Pipeline.Workspace)' # string. Alias: path. Required. File or directory path. Default: $(Pipeline.Workspace).
    #artifact: # string. Alias: artifactName. Artifact name. 
    publishLocation: 'pipeline' # 'pipeline' | 'filepath'. Alias: artifactType. Required. Artifact publish location. Default: pipeline.
    #fileSharePath: # string. Required when artifactType = filepath. File share path. 
    #parallel: false # boolean. Optional. Use when artifactType = filepath. Parallel copy. Default: false.
    #parallelCount: '8' # string. Optional. Use when artifactType = filepath && parallel = true. Parallel count. Default: 8.

輸入

targetPath - 檔案或目錄路徑
輸入別名: pathstring. 必要。 預設值:$(Pipeline.Workspace)

指定要發佈的檔案或目錄路徑。 可以是絕對或相對於預設工作目錄。 可以包含 變數,但不支援萬用字元。 如需詳細資訊 ,請參閱 Azure Pipelines 中的成品


artifact - 成品名稱
輸入別名: artifactNamestring.

指定要發佈的成品名稱。 它可以是您選擇的任何名稱,例如 drop 。 如果未設定,則預設值為限定于作業的唯一識別碼。

重要

成品名稱不能包含 \/ 、、 :><|"* 、 或 。 ?


publishLocation - 成品發佈位置
輸入別名: artifactTypestring. 必要。 允許的值: pipeline (Azure Pipelines) , filepath (檔案共用) 。 預設值:pipeline

指定是否要將成品儲存在 Azure Pipelines 中,或將它複製到必須可從管線代理程式存取的檔案共用。


fileSharePath - 檔案共用路徑
string. 當 artifactType = filepath 時為必要。

指定複製成品檔案的檔案共用。 這可以包含變數,例如 \\my\\share\\$(Build.DefinitionName)\\$(Build.BuildNumber) 。 不支援將成品從 Linux 或 macOS 代理程式發佈至檔案共用,例如 \\server\folderName


parallel - 平行複製
boolean. 選擇性。 使用 時 artifactType = filepath 。 預設值:false

指定是否要使用多個執行緒平行複製檔案,以取得更大的潛在輸送量。 如果未啟用此設定,將會使用一個執行緒。


parallelCount - 平行計數
string. 選擇性。 使用 時 artifactType = filepath && parallel = true 。 預設值:8

指定平行處理原則的程度,或用來執行複製的執行緒數目。 值必須介於 1 到 128 之間。


properties - 自訂屬性
string.

指定要與成品建立關聯的自訂屬性。 在所有索引鍵上使用具有前置 user- 詞的有效 JSON 字串。


工作控制選項

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

輸出變數

無。

備註

傳統發行管線不支援發佈。

注意

內部部署不支援發佈管線成品。 如果您使用 Azure DevOps Server 或 TFS 2018,請使用發行組建成品。 如果您在Azure DevOps Server使用它,您會收到類似 Pipeline Artifact Task is not supported in on-premises. Please use Build Artifact Task instead. 的錯誤訊息。

publishdownload 關鍵字是PublishPipelineArtifact@1和DownloadPipelineArtifact@2工作的快捷方式。 如需詳細資訊,請參閱 steps.publishsteps.download

提示

您可以使用 .artifactignore 檔案來控制要發佈的檔案。

我在發佈成品時遇到問題。 如何檢視詳細的記錄?

若要啟用管線的詳細記錄:

  1. 編輯管線並選取 [變數]
  2. 使用名稱和 System.Debug 值新增變數 true
  3. 儲存

哪些變數可供我使用?

答: $(Build.SourcesDirectory)$(Agent.BuildDirectory) 只是您可以在管線中使用的幾個變數。 變數可用為 運算式 或腳本。

請參閱 定義變數預先定義的變數傳統發行和成品變數 ,以瞭解不同類型的變數。

工作可讓我在 yaml 管線中的部署作業中發佈成品,但我無法在下游管線中使用成品?

答:部署作業沒有來源分支的內容,因此不適合發佈成品。 它們主要是設計來取用成品。 因應措施是將該邏輯隔離成個別的作業, (與部署作業相依性) 。

規格需求

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

另請參閱