title: Get git branch name in Jenkins Pipeline/Jenkinsfile
body: <p>I've create a jenkins pipeline and it is pulling the pipeline script from scm.<br>
  I set the branch specifier to '<code>all</code>', so it builds on any change to any branch. </p>
  
  <p>How do I access the branch name causing this build from the Jenkinsfile?  </p>
  
  <p>Everything I have tried echos out null except </p>
  
  <pre><code>sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim()
  </code></pre>
  
  <p>which is always <code>master</code>.</p>