-task setGitVals {
-
- doFirst {
- def hashStdOut = new ByteArrayOutputStream()
- def resultHash = exec {
- commandLine "git", "rev-parse", "--short", "HEAD"
- standardOutput = hashStdOut
- ignoreExitValue true
- }
-
- def branchStdOut = new ByteArrayOutputStream()
- def resultBranch = exec {
- commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
- standardOutput = branchStdOut
- ignoreExitValue true
- }
-
- gitHash = resultHash.getExitValue() == 0 ? hashStdOut.toString().trim() : "NO_GIT_COMMITID_FOUND"
- gitBranch = resultBranch.getExitValue() == 0 ? branchStdOut.toString().trim() : "NO_GIT_BRANCH_FOUND"
- }
-
- outputs.upToDateWhen { false }
-}
-
-