I am looking at a way of extracting out the name of "Source (build pipeline)" value in a Release from a build artifact screen.
In the attached screenshot the "Source (build pipeline)" value (in red circle) is "Subscriber-Build", whereas the Source Alias always has the _ underscore character, e.g. "_SubscriberBuild"
I've tried the following variable and variations of:
$(Release.Artifacts.{$(Release.PrimaryArtifactSourceName)}.DefinitionName)
as suggested here but with no success.
Is this actually possible?
The answer of 4c74356b41 it's correct, if it's your primary artifact you can use just Build.DefinitionName
.
But, if you want to use the variable mentioned in the docs you can get the value in this way (in 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
In the above way you can get the build definition name although is not your primary artifact, just change the first line, for example: triggerAlias = $env:Release_TriggeringArtifact_Alias
for triggered artifacts.