title: Jenkins - Pipeline access git branch name
body: <p><strong>Question:</strong> Is there any way to get the name of the branch that is checkout by the Pipeline in a jenkinsfile?</p>
  
  <p><strong>NOTE</strong>: I am not in a Multibranch Pipeline!</p>
  
  <p>In my pipeline im using </p>
  
  <pre><code>checkout([$class: 'GitSCM', 
            userRemoteConfigs: [[url:'https://github.com/repo', 
                                 credentialsId: 'xxxx',name: '1234']]])
  </code></pre>
  
  <p>where <code>name</code> is the commit ID. I need to verify that this commit id is from the branch that a user has specified as parameter (user specifies both branch name and commit id and I need to check if there is no error before building the project).</p>
  
  <p>Why is the branch name not exposed in Pipeline but only in Multibranch Pipeline? Doesn't make sense to me.</p>
  
  <p>There are three reasons why I don't want to convert to the multi branch pipeline:</p>
  
  <ol>
  <li>I am using another plugin <a href="https://wiki.jenkins.io/display/JENKINS/Build+Blocker+Plugin?focusedCommentId=64684089" rel="nofollow noreferrer">Build Blocker Plugin</a> in my pipeline that doesn't seem available in the multibranch pipeline.</li>
  <li>I have a parameterized pipeline, I don't see that option in the multibranch pipeline.</li>
  <li>A lot of time has gone into this pipeline, I simply don't want to set up this project again from scratch just for this branch name feature.</li>
  </ol>
  
  <p>I have printed out all environment variables, branch name is not among them. </p>
  
  <p>Thanks for the help!</p>