I have a Jenkins Pipeline job which is configured to checkout a git repo and a specific local branch.
How can i get the name of the local branch in my Jenkinsfile?<
I'm now using the sh call to get the branch name. This requires at least version 2.4 of the Pipeline Nodes and Processes Plugin.
def branchName = sh(returnStdout: true, script: 'git rev-parse --abbrev-ref HEAD').trim() echo branchName