From c12b14543d01d7bb497a043b127f49eb72f16a69 Mon Sep 17 00:00:00 2001 From: Anna Babu Palathingal <148897727+annaibm@users.noreply.github.com> Date: Fri, 1 Nov 2024 09:30:27 -0400 Subject: [PATCH] added change to check child job abort --- buildenv/jenkins/JenkinsfileBase | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/buildenv/jenkins/JenkinsfileBase b/buildenv/jenkins/JenkinsfileBase index a558d1a5c4..f1564ad02f 100644 --- a/buildenv/jenkins/JenkinsfileBase +++ b/buildenv/jenkins/JenkinsfileBase @@ -793,14 +793,23 @@ def runTest( ) { } } } catch (Exception e) { - handleException(e) - } finally { - // Cleanup: Terminate any running processes if the build was aborted - if (wasAborted || currentBuild.result == 'ABORTED') { - echo "Cleaning up any running child jobs due to build being aborted..." - // Add logic to abort child processes if necessary - // Example: sh "pkill -f 'your_process_name'" - } + println("Exception: " + e.toString()) + if (e.toString().contains("FlowInterruptedException")) { + currentBuild.result = 'ABORTED' + } else { + currentBuild.result = 'FAILURE' + } + + } finally { + if (currentBuild.rawBuild.isInterrupted()) { + println("Parent job is aborted. Aborting any child jobs...") + // Add code to abort child jobs, if any are running + for (child in currentBuild.rawBuild.getDownstreamBuilds()) { + if (child.isBuilding()) { + child.doStop() + } + } + } } if (params.CODE_COVERAGE) {