Neil70
Neil70

Reputation: 119

Azure Devops Release Pipelines - Variable to obtain the Source (build pipeline) value?

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?

Upvotes: 3

Views: 4330

Answers (2)

Shayki Abramczyk
Shayki Abramczyk

Reputation: 41775

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.

Upvotes: 2

4c74356b41
4c74356b41

Reputation: 72201

for the primary artifact you can just use $(Build.DefinitionName) to retrieve its build definition name as the document suggests

Upvotes: 1

Related Questions