Skip to content

Commit c12b145

Browse files
committed
added change to check child job abort
1 parent f4909f4 commit c12b145

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

buildenv/jenkins/JenkinsfileBase

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -793,14 +793,23 @@ def runTest( ) {
793793
}
794794
}
795795
} catch (Exception e) {
796-
handleException(e)
797-
} finally {
798-
// Cleanup: Terminate any running processes if the build was aborted
799-
if (wasAborted || currentBuild.result == 'ABORTED') {
800-
echo "Cleaning up any running child jobs due to build being aborted..."
801-
// Add logic to abort child processes if necessary
802-
// Example: sh "pkill -f 'your_process_name'"
803-
}
796+
println("Exception: " + e.toString())
797+
if (e.toString().contains("FlowInterruptedException")) {
798+
currentBuild.result = 'ABORTED'
799+
} else {
800+
currentBuild.result = 'FAILURE'
801+
}
802+
803+
} finally {
804+
if (currentBuild.rawBuild.isInterrupted()) {
805+
println("Parent job is aborted. Aborting any child jobs...")
806+
// Add code to abort child jobs, if any are running
807+
for (child in currentBuild.rawBuild.getDownstreamBuilds()) {
808+
if (child.isBuilding()) {
809+
child.doStop()
810+
}
811+
}
812+
}
804813
}
805814

806815
if (params.CODE_COVERAGE) {

0 commit comments

Comments
 (0)