共用方式為


PublishBuildArtifacts@1 - 發佈組建成品 v1 工作

在組建管線中使用這項工作,將組建成品發佈至 Azure Pipelines、TFS 或檔案共用。

如果您使用 Azure DevOps Services,建議您使用下載管線成品發佈管線成品,以加快效能。

在組建管線中使用這項工作,將組建成品發佈至 Azure Pipelines、TFS 或檔案共用。

Syntax

# Publish build artifacts v1
# Publish build artifacts to Azure Pipelines or a Windows file share.
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)' # string. Required. Path to publish. Default: $(Build.ArtifactStagingDirectory).
    ArtifactName: 'drop' # string. Required. Artifact name. Default: drop.
    publishLocation: 'Container' # 'Container' | 'FilePath'. Alias: ArtifactType. Required. Artifact publish location. Default: Container.
    #MaxArtifactSize: '0' # string. Max Artifact Size. Default: 0.
    #TargetPath: # 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.
  # Advanced
    #StoreAsTar: false # boolean. Tar the artifact before uploading. Default: false.
# Publish build artifacts v1
# Publish build artifacts to Azure Pipelines or a Windows file share.
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)' # string. Required. Path to publish. Default: $(Build.ArtifactStagingDirectory).
    ArtifactName: 'drop' # string. Required. Artifact name. Default: drop.
    publishLocation: 'Container' # 'Container' | 'FilePath'. Alias: ArtifactType. Required. Artifact publish location. Default: Container.
    #TargetPath: # 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.
  # Advanced
    #FileCopyOptions: # string. Optional. Use when ArtifactType = FilePath. File copy options. 
    #StoreAsTar: false # boolean. Tar the artifact before uploading. Default: false.
# Publish build artifacts v1
# Publish build artifacts to Azure Pipelines or a Windows file share.
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)' # string. Required. Path to publish. Default: $(Build.ArtifactStagingDirectory).
    ArtifactName: 'drop' # string. Required. Artifact name. Default: drop.
    publishLocation: 'Container' # 'Container' | 'FilePath'. Alias: ArtifactType. Required. Artifact publish location. Default: Container.
    #TargetPath: # 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.
  # Advanced
    #FileCopyOptions: # string. Optional. Use when ArtifactType = FilePath. File copy options.
# Publish build artifacts v1
# Publish build artifacts to Azure Pipelines or a Windows file share.
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)' # string. Required. Path to publish. Default: $(Build.ArtifactStagingDirectory).
    ArtifactName: 'drop' # string. Required. Artifact name. Default: drop.
    publishLocation: 'Container' # 'Container' | 'FilePath'. Alias: ArtifactType. Required. Artifact publish location. Default: Container.
    #TargetPath: # 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.
# Publish Build Artifacts v1
# Publish build artifacts to Azure Pipelines/TFS or a file share.
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)' # string. Required. Path to publish. Default: $(Build.ArtifactStagingDirectory).
    ArtifactName: 'drop' # string. Required. Artifact name. Default: drop.
    publishLocation: 'Container' # 'Container' | 'FilePath'. Alias: ArtifactType. Required. Artifact publish location. Default: Container.
    #TargetPath: # 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.

輸入

PathtoPublish - 發佈路徑
string. 必要。 預設值:$(Build.ArtifactStagingDirectory)

指定要發佈的資料夾或檔案路徑。 這可以是完整路徑或相對於存放庫根目錄的路徑。 不支援萬用字元。 支援變數。 範例: $(Build.ArtifactStagingDirectory). 如需詳細資訊,請參閱 管線中的成品 - 概觀


ArtifactName - 成品名稱
string. 必要。 預設值:drop

指定要在發佈位置中建立的成品名稱。 不允許下列特殊字元: +、、 %{}


publishLocation - 成品發佈位置
輸入別名: ArtifactTypestring. 必要。 允許的值: Container (Azure Pipelines) , FilePath (檔案共享) 。 預設值:Container

指定是否要將成品儲存在 Azure Pipelines (Container) ,或將它複製到必須可從組建代理程式存取的檔案共用 (FilePath) 。 如需詳細資訊,請參閱 Azure Pipelines 中的成品


publishLocation - 成品發佈位置
輸入別名: ArtifactTypestring. 必要。 允許的值: Container (Azure Pipelines/TFS) , FilePath (檔案共享) 。 預設值:Container

指定是否要將成品儲存在 Azure Pipelines (Container) ,或將它複製到必須可從組建代理程式存取的檔案共用 (FilePath) 。 如需詳細資訊,請參閱 Azure Pipelines 中的成品


MaxArtifactSize - 成品大小上限
string. 預設值:0

要以位元組為單位發佈的成品大小上限。 如果您不想設定任何限制,請放置 0。


TargetPath - 檔案共享路徑
string. 當 ArtifactType = FilePath 時為必要。

指定要複製檔案的檔案共享路徑。 路徑必須是完整路徑,或相對於存放庫根目錄的有效路徑。 不支援將成品從Linux或macOS代理程式發佈至檔案共用。 範例: \\my\share\$(Build.DefinitionName)\$(Build.BuildNumber).


Parallel - 平行複製
boolean. 選擇性。 使用 時 ArtifactType = FilePath。 預設值:false

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


ParallelCount - 平行計數
string. 選擇性。 使用 時 ArtifactType = FilePath && Parallel = true。 預設值:8

指定平行處理原則的程度, (用來執行複製的線程數目) 。 此值必須至少為 1,且不能大於 128。 根據組建代理程式的CPU功能選擇值。


StoreAsTar - 上傳前先將成品 Tar
boolean. 預設值:false

在上傳之前,將發佈路徑中的所有檔案新增至 tar 封存。 這可讓您保留 UNIX 檔案許可權。 使用 extractTarsDownloadBuildArtifacts 工作的選項自動擷取下載的專案。 Windows 代理程式會忽略此設定。


FileCopyOptions - 檔案複製選項
string. 選擇性。 使用 時 ArtifactType = FilePath

將其他選項傳遞至 Robocopy 命令。 例如,遞迴迷你圖樣 **/*


工作控制選項

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

輸出變數

無。

備註

注意

您無法使用 IIS 保留的 BinApp_Data 和其他資料夾名稱作為成品名稱,因為此內容並未提供以回應 Web 要求。 如需詳細資訊 ,請參閱 ASP.NET Web 專案資料夾結構

範例

steps:
- task: CopyFiles@2
  inputs:
    contents: '_buildOutput/**'
    targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: $(Build.ArtifactStagingDirectory)
    artifactName: MyBuildOutputs

規格需求

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

另請參閱