Azure Devops Release Pipelines - 用于获取源(构建管道)值的变量?

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

我正在寻找一种从构建工件屏幕中提取版本中“源(构建管道)”值的名称的方法。

attached screenshot中,“源(构建管道)”值(红色圆圈中)是“订阅者构建”,而源别名始终具有 _ 下划线字符,例如“_SubscriberBuild”

我尝试了以下变量和变体:

$(Release.Artifacts.{$(Release.PrimaryArtifactSourceName)}.DefinitionName)

按照建议here但没有成功。

这真的可能吗?

azure-devops azure-pipelines azure-pipelines-release-pipeline azure-artifacts
2个回答
2
投票

4c74356b41的答案是正确的,如果它是你的主要神器,你可以只使用

Build.DefinitionName

但是,如果您想使用文档中提到的变量,您可以通过这种方式获取值(在 PowerShell 中):

$primaryAlias = $env:Release_PrimaryArtifactSourceAlias

$definitionVariable = "Release_Artifact_$($primaryAlias)_DefinitionName"

# Get the value of the environment variable Release.Artifact.{alias}.DefnitionName:

$primaryDefnitionName = (Get-Item env:$defnitionVariable).Value

通过上述方式,您可以获得构建定义名称,尽管不是您的主要工件,只需更改第一行,例如:

triggerAlias = $env:Release_TriggeringArtifact_Alias
表示触发的工件。


1
投票

对于主要工件,您只需使用

$(Build.DefinitionName)
即可按照文档的建议检索其构建定义名称

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