From 3fcff3b9c8f3d317ae26c381fe4a1afadd5dd539 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Fri, 15 Nov 2024 09:18:08 +0100 Subject: [PATCH] catch exception when determining git branch --- .../hsadminng/hs/office/scenarios/TestReport.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java index 2baa3a62..ec6e0fd6 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/TestReport.java @@ -121,8 +121,14 @@ public class TestReport { @SneakyThrows private String currentGitBranch() { - final var gitRevParse = new SystemProcess("git", "rev-parse", "--abbrev-ref", "HEAD"); - gitRevParse.execute(); - return gitRevParse.getStdOut().split("\\R", 2)[0]; + try { + final var gitRevParse = new SystemProcess("git", "rev-parse", "--abbrev-ref", "HEAD"); + gitRevParse.execute(); + return gitRevParse.getStdOut().split("\\R", 2)[0]; + } catch (final IOException exc) { + // TODO.test: the git call does not work in Jenkins, we have to find out why + System.err.println(exc); + return "unknown"; + } } }