ArturSkowronski
2/15/2015 - 3:47 PM

Get Working branch in Gradle Build

Get Working branch in Gradle Build

def getWorkingBranch() {
    // Triple double-quotes for the breaklines
    def workingBranch = """git --git-dir=${rootDir}/../.git
                               --work-tree=${rootDir}/..
                               rev-parse --abbrev-ref HEAD""".execute().text.trim()
    print "Working branch: " + workingBranch
    return workingBranch
}