ADO 任务下载与 DownloadPipelineArtifact@2

问题描述 投票:0回答:1

我正在设置一个需要由另一个构建管道触发的构建作业。

trigger:
- main

resources:
  pipelines:
  - pipeline: triggeredpipeline # Name of the pipeline resource.
    source: <pipeline path and name> # The name of the pipeline referenced by this pipeline resource.
    project: <ADO project name> # Required only if the source pipeline is in another project
    trigger: true # Run app-ci pipeline when any run of security-lib-ci completes

pool: Default

下一步是从触发作业中获取工件,以在触发的构建作业中发挥作用。

现在我遇到了 ADO“下载”(https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/steps-download?view=azure-pipelines)允许的情况我重用管道引用,但不允许我显式指定目标位置。

  - download: triggeredpipeline  # pipeline resource identifier.
    displayName: Download files from triggering pipeline
    artifact: Platform

它将如文档中所述,将其写入

$(Pipeline.Workspace)/<pipeline resource identifier>/<artifact name>
,例如/triggeredpipeline/Platform(或平台中的内容)

现在文档指出

download
是 DownloadPipelineArtifact@2 的简写,并且根据该文档(https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/download- pipeline-artifact-v2?view=azure-pipelines) 可以指定
targetPath
。我没有看到/不明白如何重用我的管道参考。我只能设置触发我的构建的项目和管道的 id。

- task: DownloadPipelineArtifact@2
  inputs:
    buildType: 'specific'
    project: '<uuid>'
    definition: '266'
    buildVersionToDownload: 'latest'
    artifactName: 'Platform'
    targetPath: '$(Build.ArtifactStagingDirectory)'

那么我如何使用对触发器的引用(

pipeline: triggeredpipeline
),但仍然能够定义目标文件夹是什么。

(是的,我可以添加一些执行复制的任务,但是源工件的大小相当大,因此下载,然后再次移动/复制它是浪费时间)

我希望你们中的一个人以前使用过触发构建管道,并知道一种重用触发器引用以一次性将工件下载到正确位置的方法。

azure-devops download azure-pipelines ado azure-pipelines-yaml
1个回答
0
投票

您正在寻找

specificBuildWithTriggering
旗帜。

来自文档:

别名:preferTriggeringPipeline。选修的。当来源==特定时使用。在适当的时候,从触发构建中下载工件。

© www.soinside.com 2019 - 2024. All rights reserved.