Prevent build from crashing when no Git or on Windows

This commit is contained in:
Eugene Cheung 2017-12-16 10:52:30 -05:00 committed by Eugene
commit 0eff79ca1a

View file

@ -20,11 +20,20 @@ repositories {
} }
static def gitBranch() { static def gitBranch() {
def branch = '' def branch = 'GitHub'
def proc = 'git rev-parse --abbrev-ref HEAD'.execute() try {
proc.in.eachLine { line -> branch = line } def gitcheck = 'command -v git >/dev/null 2>&1'.execute()
proc.err.eachLine { line -> println line } gitcheck.waitFor()
proc.waitFor() if (gitcheck.exitValue() == 0) {
def proc = 'git rev-parse --abbrev-ref HEAD'.execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
}
} catch (Exception e) {
// Do nothing
println e
}
branch branch
} }