title: How can I read a GIT tag from the current branch into a variable?
body: <p>I want to use git tags within my declarative Jenkins pipeline. My Jenkinsfile looks like this</p>
  
  <pre><code>pipeline {
      agent any
      stages {
          stage('Setup') {
              steps {
                  script {
                      env.MY_GIT_TAG = sh(returnStdout: true, script: 'git tag -l --points-at HEAD')
                      // ... 
                  }
              }
          }
          stage('Build'){
              // build my code etc ....
          }
          stage('Publish') {
              // push code somewhere depending on tag
              sh "curl -X POST --upload-file ./MyDeployable https://someserver/uri/MyDeployable-${env.MY_GIT_TAG}"
          }
      }
  }
  </code></pre>
  
  <p>But the environment variable <code>MY_GIT_TAG</code> was always empty. After some investigation i noticed this in my Jenkins logs:
  <code>git fetch --no-tags --progress ...</code></p>
  
  <p>Is there a way to tell Jenkins to skip the <code>--no-tags</code> argument?</p>
  
  <p>As i do not know beforehand how the commit is tagged i want to checkout the tag from git and use it as a variable. So the solution in <a href="https://stackoverflow.com/questions/10195900/jenkins-git-plugin-how-to-build-specific-tag">this question</a> is not viable here.</p>