Azure devops 忽略使用从UI中的资源中选择的工件手动运行YAML构建管道

Azure devops 忽略使用从UI中的资源中选择的工件手动运行YAML构建管道,azure-devops,azure-pipelines,Azure Devops,Azure Pipelines,我们有一个YAML文件(pipelineB),它完成它必须做的事情,它从特定的其他现有构建管道(pipelineA)下载最新的构建工件。这是自动触发的。现在我们想要手动运行这个构建pipelineB,并且能够选择要使用的另一个工件版本。在Azure DevOps构建管道中,有一个选项称为“运行管道”,您可以在其中选择要使用的“资源”。如果您选择了一个资源,您将得到一个列表,其中列出了来自pipelineA的所有构建,您可以从中进行选择 然后,如果我们从管道运行的pipelineA和运行的p

我们有一个YAML文件(
pipelineB
),它完成它必须做的事情,它从特定的其他现有构建管道(
pipelineA
)下载最新的构建工件。这是自动触发的。现在我们想要手动运行这个构建
pipelineB
,并且能够选择要使用的另一个工件版本。在Azure DevOps构建管道中,有一个选项称为“运行管道”,您可以在其中选择要使用的“资源”。如果您选择了一个资源,您将得到一个列表,其中列出了来自
pipelineA
的所有构建,您可以从中进行选择

然后,如果我们从管道运行的
pipelineA
和运行的
pipelineB
中选择较旧的版本(例如
1.2.43-10019-master
),并查看日志,我们会发现它忽略了我们手动选择的内容,并且总是下载最新版本。我可以理解它之所以这样做是因为
DownloadBuildArtifact@0
步骤告诉您使用
latestfrombrack
生成版本下载

我的问题:我们如何利用手动选择资源构建工件并在YAML管道中进一步使用所选版本?理想情况下,如果您不进行手动运行/选择,它应该只使用工件的最新版本

下面是我们的YAML管道的一个exerpt:

name: pipelineB

resources:
  pipelines:

  - pipeline: pipelineA
    source: pipelineA
    branch: master
    trigger:
      branches:
        - master

steps:

  - task: DownloadBuildArtifacts@0
    name: 
    displayName: 'Download pipelineA artifact'
    inputs:
      buildtype: specific
      project: ourProjectName
      pipeline: pipelineA
      branchName: refs/heads/master
      buildVersionToDownload: latestFromBranch
      downloadType: specific
      downloadPath: $(Pipeline.Workspace)
基于@Krzysztof Madej回答的工作解决方案。只是为了台阶
DownloadBuildArtifacts@0
需要将字段
buildVersionDownload
更改为
specific
,并且需要引入一个新字段
buildId
,引用
pipelineA
资源

steps:

  - task: DownloadBuildArtifacts@0
    name: 
    displayName: 'Download pipelineA artifact'
    inputs:
      buildtype: specific
      project: ourProjectName
      pipeline: pipelineA
      branchName: refs/heads/master
      buildVersionToDownload: 'specific'
      downloadType: specific
      buildId: '$(resources.pipeline.pipelineA.runID)'
      downloadPath: $(Pipeline.Workspace)

请将
buildVersionToDownload
更改为
specific
,然后使用
buildId:'$(resources.pipeline.hadar.runID)

-任务:DownloadBuildArtifacts@0
投入:
buildType:“特定”
项目:“4fa6b279-3db9-4cb0-aab8-e06c2ad550b2”
管道:“72”
branchName:'裁判/负责人/大师'
buildVersionToDownload:“特定”
下载类型:'single'
下载路径:“$(Pipeline.Workspace)”
工件名称:“drop”
buildId:“$(resources.pipeline.hadar.runID)”
您可以检查管道资源的可用变量

resources.pipeline..projectName
资源.管道..项目
resources.pipeline..pipelineName
resources.pipeline..pipelineID
resources.pipeline..runName
resources.pipeline..runID
resources.pipeline..runURI
resources.pipeline..sourceBranch
resources.pipeline..sourceCommit
resources.pipeline..sourceProvider
resources.pipeline..requestedFor
resources.pipeline..requestedForID
我又检查了一遍,很简单

-下载:pipelineA

与上面的代码相同。

请将
buildVersionDownload
更改为
specific
,然后使用
buildId:'$(resources.pipeline.hadar.runID)

-任务:DownloadBuildArtifacts@0
投入:
buildType:“特定”
项目:“4fa6b279-3db9-4cb0-aab8-e06c2ad550b2”
管道:“72”
branchName:'裁判/负责人/大师'
buildVersionToDownload:“特定”
下载类型:'single'
下载路径:“$(Pipeline.Workspace)”
工件名称:“drop”
buildId:“$(resources.pipeline.hadar.runID)”
您可以检查管道资源的可用变量

resources.pipeline..projectName
资源.管道..项目
resources.pipeline..pipelineName
resources.pipeline..pipelineID
resources.pipeline..runName
resources.pipeline..runID
resources.pipeline..runURI
resources.pipeline..sourceBranch
resources.pipeline..sourceCommit
resources.pipeline..sourceProvider
resources.pipeline..requestedFor
resources.pipeline..requestedForID
我又检查了一遍,很简单

-下载:pipelineA

与上面的代码一样工作。

Hi@tjeernet,只是想看看这个问题现在是否还在阻碍您?这个问题有更新吗?如果答案可以帮助,你可以考虑。@ VITIUU MSFT I今天有机会测试它,并更新我的问题与答案。它现在可以按预期工作:)-尽管我发现在Azure DevOps管道文档中很难找到这样的内容,即如果您进行手动构建并选择其他资源,它会覆盖下载任务
runID
Hi@tjeernet,只是检查一下这个问题现在是否仍在阻止您?这个问题有更新吗?如果答案可以帮助,你可以考虑。@ VITIUU MSFT I今天有机会测试它,并更新我的问题与答案。它现在可以像预期的那样工作:)-尽管我发现在Azure DevOps管道文档中很难找到这一点,如果您手动构建并选择不同的资源,它会覆盖下载任务
runID