title: How to assign git commit hash to a variable in Jenkins File
body: <p>I am trying to  assign the git commit hash to a variable defines in Jenkins pipeline as follows </p>
  
  <pre><code>GIT_COMMIT_HASH = sh "(git log -n 1 --pretty=format:'%H')"
  </code></pre>
  
  <p>This will print the commit hash in Jenkins build log but it fails to assign the value. </p>
  
  <p>When I try to print the value using </p>
  
  <pre><code>steps{
      script {
                  GIT_COMMIT_HASH = sh "(git log -n 1 --pretty=format:'%H')"
  
                  echo "**************************************************"
                  echo "${GIT_COMMIT_HASH}"
                  echo "**************************************************"
      }
  }
  </code></pre>
  
  <p>This will results null</p>
  
  <p>How may I assign the value ?</p>