title: Git tag name in Azure Devops Pipeline YAML
body: <p><strong>Summary</strong></p>
  
  <p>How do I get the name of the current git tag in an Azure Devops Pipeline YAML-file?</p>
  
  <p><strong>What Am I Trying to Do?</strong></p>
  
  <p>I am setting up a build pipeline in Azure Devops. The pipeline triggers when a new git tag is created. I then want to build docker images and tag them with the git tag's name.</p>
  
  <p>My YAML pipeline looks something like this:</p>
  
  <pre><code># Trigger on new tags.
  trigger:
    tags:
      include:
      - '*'
  
  stages:
  - stage: Build
    jobs:
    - job: Build
      pool:
        vmImage: 'ubuntu-latest'
  
      steps:
      - script: export VERSION_TAG={{ SOMEHOW GET THE VERSION TAG HERE?? }}
        displayName: Set the git tag name as environment variable
  
      - script: docker-compose -f k8s/docker-compose.yml build
        displayName: 'Build docker containers'
  
      - script: docker-compose -f k8s/docker-compose.yml push
        displayName: 'Push docker containers'
  </code></pre>
  
  <p>And the docker-compose file I am referencing something like this:</p>
  
  <pre><code>version: '3'
  services:
    service1:
      image: my.privaterepo.example/app/service1:${VERSION_TAG}
      build:
        [ ... REDACTED ]
    service2:
      image: my.privaterepo.example/app/service2:${VERSION_TAG}
      build:
        [ ... REDACTED ]
  </code></pre>
  
  <p>As you can see, the tag name in the docker-compose file is taken from the environment variable <code>VERSION_TAG</code>. In the YAML pipeline, I am trying to set the environment variable <code>VERSION_TAG</code> based on the current GIT tag. So... how do I get the name of the tag?</p>