从引用的管道资源中获取最新的构建 ID [英] Getting the latest build id from a referenced pipeline resource

查看:18
本文介绍了从引用的管道资源中获取最新的构建 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在经典发布管道中,可以添加其他管道作为工件资源 - 这些可以是触发器,也可以只是引用.然后,您可以参考有关它们的信息,例如使用 $(Release.Artifacts.ARTIFACTNAME.BuildId) 的构建 ID.

In the classic release pipeline it was possible to add other pipelines as Artifact resources - these could be triggers, or just references. You could then reference information about them, e.g. the build id using $(Release.Artifacts.ARTIFACTNAME.BuildId).

您现在可以做某事类似在多阶段 yaml 管道中:

You can now do something similar in a multi-stage yaml pipeline:

resources:
  pipelines:
  - pipeline: MyBuild
    source: My build pipeline name 
    trigger: 
      branches:
      - master

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: Write-Host Referenced pipeline build id is: ???

但是根据上面的 PowerShell 步骤,我找不到一种方法来获取以这种方式关联的资源的构建 ID,而且我还没有在文档中找到任何内容.

But as per the PowerShell step above, I can't find a way to get the build id of a resource associated in this way, and I can't spot anything in the documentation yet.

我做过的一些绝望的尝试是:

Some desperate attempts I've made are:

$(Release.Artifacts.MyBuild.BuildId)
$(resources.MyBuild.BuildId)
$(BuildId@MyBuild)

有谁知道如何做到这一点?

Does anyone know how this can be done?

推荐答案

最新的发行说明有一组新的预定义变量.

The newest release notes has a new set of predefined variables.

resources.pipeline.{Alias}.projectName 
resources.pipeline.{Alias}.projectID 
resources.pipeline.{Alias}.pipelineName 
resources.pipeline.{Alias}.pipelineID 
resources.pipeline.{Alias}.runName 
resources.pipeline.{Alias}.runID
resources.pipeline.{Alias}.runURI
resources.pipeline.{Alias}.sourceBranch 
resources.pipeline.{Alias}.sourceCommit
resources.pipeline.{Alias}.sourceProvider 
resources.pipeline.{Alias}.requestedFor
resources.pipeline.{Alias}.requestedForID

见这里https://docs.microsoft.com/en-us/azure/devops/release-notes/2019/sprint-160-update#pipeline-resource-meta-data-as-预定义变量

这篇关于从引用的管道资源中获取最新的构建 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆