diff --git a/helpers.groovy b/helpers.groovy index c07e2cb..c0f7869 100644 --- a/helpers.groovy +++ b/helpers.groovy @@ -14,6 +14,20 @@ def setSuccessCheck(String name, String title) { } /* -------------------------------------------------------------------------- */ /** +* +* Helper function that emits `Success` status. +* +*/ +def setFailureCheck(String name, String title) { + publishChecks( + name: name, + title: title, + summary: '— Failed', + conclusion: "FAILURE" + ) +} +/* -------------------------------------------------------------------------- */ +/** * Replacement for `stage` function for default pipeline. * * Has the same arguments but does side-effects to the stage: @@ -25,8 +39,13 @@ def setSuccessCheck(String name, String title) { */ def stageWithChecks(String name, Closure body) { stage(name) { - body() - setSuccessCheck(name, name) + try { + body() + setSuccessCheck(name, name) + } catch (error) { + sh "echo Stage $name failed with error: $error" + setFailureCheck(name, name) + } } } /* -------------------------------------------------------------------------- */