Azure Devops 发布管道 - 获取源(构建管道)值的变量?
Azure Devops Release Pipelines - Variable to obtain the Source (build pipeline) value?
我正在研究一种从构建工件屏幕的发布中提取 "Source (build pipeline)" 值名称的方法。
在 attached screenshot 中,"Source (build pipeline)" 值(红色圆圈中)为 "Subscriber-Build",而源别名始终具有 _ 下划线字符,例如“_SubscriberBuild”
我尝试了以下变量和变体:
$(Release.Artifacts.{$(Release.PrimaryArtifactSourceName)}.DefinitionName)
按照建议 here 但没有成功。
这真的可能吗?
对于主要工件,您可以使用 $(Build.DefinitionName)
来检索其构建定义名称,如文档所建议的那样
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_TriggeringArtifacts_Alias
用于触发工件。
我正在研究一种从构建工件屏幕的发布中提取 "Source (build pipeline)" 值名称的方法。
在 attached screenshot 中,"Source (build pipeline)" 值(红色圆圈中)为 "Subscriber-Build",而源别名始终具有 _ 下划线字符,例如“_SubscriberBuild”
我尝试了以下变量和变体:
$(Release.Artifacts.{$(Release.PrimaryArtifactSourceName)}.DefinitionName)
按照建议 here 但没有成功。
这真的可能吗?
对于主要工件,您可以使用 $(Build.DefinitionName)
来检索其构建定义名称,如文档所建议的那样
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_TriggeringArtifacts_Alias
用于触发工件。