简体   繁体   English

从多级 YAML 中的其他管道下载工件

[英]Download Artifact from other pipeline in Multistage YAML

In azure devops i am trying to create a multistage release definition via yaml.在 azure devops 中,我试图通过 yaml 创建多阶段发布定义。 Build is done via classic editor and the artifacts are uploaded to azure pipelines.通过经典编辑器完成构建,并将工件上传到 azure 管道。 so i want to access a specific artifact for deployment所以我想访问一个特定的工件进行部署

- task: DownloadPipelineArtifact@2 displayName: 'Download Pipeline Artifact' inputs: buildType: specific project: 'vvxxxxxx-vxxv-xxxv-vxxx-xxxxxxvvxxvv' definition: 5 buildVersionToDownload: specific pipelineId: 'SSE_XXXXXXXXXXXXXXXXXX_Auto-import_dev_20200423.4' artifactName: Service targetPath: '$(Pipeline.Workspace)'

When i try it via classic release using task 'Download Pipeline Artifact' it's successful but when I try it via yaml it's failing with error "##[error]Run Id is not valid: SSE_XXXXXXXXXXXXXXXXXX_Auto-import_dev_20200423.4" if there is anyother way to get the artifact from a pipeline would be helpful and also instead of hardcoding pipelineId I want to make it dynamic as well.当我使用任务“下载管道工件”通过经典版本尝试它时它是成功的,但是当我通过 yaml 尝试它时它失败并出现错误“##[error]Run Id is not valid: SSE_XXXXXXXXXXXXXXXXXX_Auto-import_dev_20200423.4”如果有任何其他方式从管道中获取工件会很有帮助,而且我也想让它动态化,而不是硬编码 pipelineId。

Download Artifact from other pipeline in Multistage YAML从多级 YAML 中的其他管道下载工件

The value of the pipelineId should be the ID of the build pipeline, which you want to download, rather than the name/title of the build pipeline. pipelineId的值应该是您要下载的构建管道的 ID,而不是构建管道的名称/标题。

Find the build pipeline you want to download, click on a build record you want to download, you could see it in the web address bar of the browser:找到您要下载的构建管道,点击您要下载的构建记录,您可以在浏览器的web地址栏中看到:

在此处输入图像描述

also instead of hardcoding pipelineId I want to make it dynamic as well.我也想让它动态化,而不是硬编码 pipelineId。

If you don't want hard code the pipelineId/runid in YAML definition, you can consider to pass queue variable as a work around.如果您不想在 YAML 定义中对pipelineId/runid进行硬编码,您可以考虑传递队列变量作为解决方法。

For example:例如:

- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    artifact: 'drop'
    path: $(Build.SourcesDirectory)/bin
    project: 'AndroidBuild'
    pipeline: 12
    runVersion: 'specific'
    runId: $(buildid)

In above definition, buildid is the variable, and you can configure its value at queue time:在上面的定义中, buildid是变量,你可以在队列时配置它的值:

在此处输入图像描述

This do not need you to do any modification to the pipeline when you want to choosing another runId, just pass the value at queue time.当您想选择另一个runId时,这不需要您对管道进行任何修改,只需在排队时传递值即可。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM