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() {
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()
def branch = 'GitHub'
try {
def gitcheck = 'command -v git >/dev/null 2>&1'.execute()
gitcheck.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
}