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 (A 文件共享) 。 默认值: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
需求
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任意
可设置的变量 任意
代理版本 2.199 或更高版本
任务类别 实用工具
要求 说明
管道类型 YAML、经典版本、经典版本
运行平台 Agent、DeploymentGroup
需求
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任意
可设置变量 任意
代理版本 2.159.2 或更高版本
任务类别 实用工具

另请参阅