title: How to set customized displayName to a Jenkins pipeline job?
body: <p>One of my customers has some freestyle Jenkins jobs which display <code>"#${BUILD_NUMBER}|${BRANCH_NAME}"</code>
  In the description or displayName of the jobs using a plugin called "Build Name Setter".</p>
  
  <p>Unfortunately, this plugin works properly only in freestyle jobs.</p>
  
  <p><a href="https://i.stack.imgur.com/ByVKp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ByVKp.jpg" alt="enter image description here"></a>
  I want to achieve the same goal but with a Jenkins pipeline job.</p>
  
  <p>I've tried adding the following line, just after the checkout step:</p>
  
  <pre><code>currentBuild.displayName = "#${BUILD_NUMBER}|${BRANCH_NAME}"
  </code></pre>
  
  <p>But I'm getting an error that "BRANCH_NAME" is not set.</p>
  
  <p>I must use the "SCM step" instead of a dedicated plugin because the repository I'm cloning is a TFS-Git repository and it's plugin doesn't have this functionality.</p>
  
  <p>This is a known issue in the behavior of SCM step specifically in pipeline jobs, but I was wondering if any of you found any workaround which I can implement to display this information in the job's page.</p>