diff --git a/build.gradle b/build.gradle index 50a7f3c0..098e1de5 100644 --- a/build.gradle +++ b/build.gradle @@ -24,17 +24,22 @@ repositories { def gitCommitHash = { -> - def stdout = new ByteArrayOutputStream() - ExecResult result = exec ()->{ - commandLine 'git', 'rev-parse', '--short', 'HEAD' - standardOutput = stdout - ignoreExitValue = true - } + try { + def stdout = new ByteArrayOutputStream() + ExecResult result = exec () -> { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = stdout + ignoreExitValue = true + } - if (result.getExitValue() != 0) { + if (result.getExitValue() != 0) { + return ""; + } else { + return stdout.toString().trim(); + } + } catch (Exception e) { + e.printStackTrace() return ""; - } else { - return stdout.toString().trim(); } }