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. 使用 发布生成项目 的错误消息。

语法

# 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。 如果未设置,则默认值为限定为作业的唯一 ID。

重要

项目名称不能包含 \/":<>|*?


publishLocation - 项目发布位置
输入别名:artifactTypestring。 必填。 允许的值:pipeline(Azure Pipelines)、filepath(文件共享)。 默认值:pipeline

指定是将项目存储在 Azure Pipelines 中,还是将其复制到必须从管道代理访问的文件共享。


fileSharePath - 文件共享路径
stringartifactType = 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,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.199.0 或更高版本
任务类别 效用
要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.199 或更高版本
任务类别 效用
要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.159.2 或更高版本
任务类别 效用

另请参阅