From 57c469d6a22b388cdc4f2a055cf4905454c48baa Mon Sep 17 00:00:00 2001 From: Anna Babu Palathingal <148897727+annaibm@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:46:59 -0400 Subject: [PATCH] Added the exception e --- buildenv/jenkins/JenkinsfileBase | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/buildenv/jenkins/JenkinsfileBase b/buildenv/jenkins/JenkinsfileBase index eefa2c075c..a558d1a5c4 100644 --- a/buildenv/jenkins/JenkinsfileBase +++ b/buildenv/jenkins/JenkinsfileBase @@ -793,14 +793,7 @@ def runTest( ) { } } } catch (Exception e) { - echo "An error occurred: ${e.message}" - if (e.toString().contains("FlowInterruptedException")) { - wasAborted = true - currentBuild.result = 'ABORTED' - echo "Build aborted by user or another trigger." - } else { - currentBuild.result = 'FAILURE' - } + handleException(e) } finally { // Cleanup: Terminate any running processes if the build was aborted if (wasAborted || currentBuild.result == 'ABORTED') { @@ -839,6 +832,17 @@ def runTest( ) { } } +def handleException(Exception e) { + // Handle exceptions and set build status accordingly + echo "An error occurred: ${e.message}" + if (e.toString().contains("FlowInterruptedException")) { + currentBuild.result = 'ABORTED' + echo "Build aborted by user or another trigger." + } else { + currentBuild.result = 'FAILURE' + } +} + def checkTestResults(results) { if (results.isEmpty()) { return