Seems like
- gradle-git plugin is no more maintained so 
GitBranchListapi will not available withGradle-6.6.1 
task getBranchName(type: GitBranchList) << {
   print getWorkingBranch().name
}
- https://stackoverflow.com/a/36760102/1665592 ... it fails on CI tools(Jenkins) if gradle wrapper isn't invoked from root of project where 
.gitdir is. It produces errorfatal: not a git repository (or any of the parent directories): .gitasGradle Wrapperis invoked by Jenkins Gradle plugin from outside of dir where.gitfolder resides. 
def gitBranch() {
    def branch = ""
    def proc = "git rev-parse --abbrev-ref HEAD".execute()
    proc.in.eachLine { line -> branch = line }
    proc.err.eachLine { line -> println line }
    proc.waitFor()
    branch
}
Both solutions doesn't work well to detect current git branch using Gradle..
How, can I get branch name properly