Search code examples
azure-devopsazure-pipelinesdevopsazure-pipelines-release-pipelinegit-tag

Azure Pipeline - Get associated git TAG?


On my pipeline, I can retrieve the build number using the variable RELEASE.ARTIFACTS.MyPipeline_BUILDID. But I was wondering, how can I get the TAG associated with the build.

It is visible within the pipeline like:

enter image description here

is there a way to capture it in a variable within the yml so I properly concatenate it like:

enter image description here


Solution

  • You can use the variable SourceBranch:

    The branch of the triggering repo the build was queued for. When your pipeline is triggered by a tag: refs/tags/your-tag-name

    So, in the release the variable will be RELEASE.ARTIFACTS.MyPipeline_SOURCEBRANCH.