diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java index f20a0d270c7..eeb3588ee0c 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java @@ -260,6 +260,9 @@ public class GlobalBuildInfoPlugin implements Plugin { } else { // this is a git worktree, follow the pointer to the repository final Path workTree = Paths.get(readFirstLine(dotGit).substring("gitdir:".length()).trim()); + if (Files.exists(workTree) == false) { + return "unknown"; + } head = workTree.resolve("HEAD"); final Path commonDir = Paths.get(readFirstLine(workTree.resolve("commondir"))); if (commonDir.isAbsolute()) {