Prevent build from crashing when no Git or on Windows
This commit is contained in:
parent
b0c98e7787
commit
0eff79ca1a
1 changed files with 14 additions and 5 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue