From 347751a82638834009b04954ebfe1e19b7d62697 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Thu, 3 Jun 2021 12:03:14 -0400 Subject: [PATCH] Fix branch name when building main branch on GH (#4193) Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com> Fixes #4191. --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 48c27f223..a072a054b 100644 --- a/build.gradle +++ b/build.gradle @@ -46,8 +46,10 @@ def commitsSinceLastTag() { @SuppressWarnings('GrMethodMayBeStatic') def headBranchName() { - if (System.getenv("GITHUB_HEAD_REF") != null) { + if (System.getenv("GITHUB_HEAD_REF") != null && !System.getenv("GITHUB_HEAD_REF").isEmpty()) { return System.getenv("GITHUB_HEAD_REF") + } else if (System.getenv("GITHUB_REF") != null && !System.getenv("GITHUB_REF").isEmpty()) { + return System.getenv("GITHUB_REF").replaceFirst("refs/heads/", "") } if (!indraGit.isPresent()) {