工具脚本 Shell脚本 获取Git分支名称 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 }