From 745bc10dc3d1b6bc424566756ed17c02914e9b39 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Wed, 20 Nov 2024 17:27:15 +0100 Subject: [PATCH] Add a new method to force shutdown a RealJenkinsRule instance --- .../java/org/jvnet/hudson/test/RealJenkinsRule.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java index 3a5dd86ee..102eedb47 100644 --- a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java +++ b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java @@ -1155,6 +1155,19 @@ public void stopJenkins() throws Throwable { } } + /** + * Stops Jenkins abruptly, without giving it a chance to shut down cleanly. + * If Jenkins is already stopped then invoking this method has no effect. + */ + public void stopJenkinsForcibly() { + if (proc != null) { + var _proc = proc; + proc = null; + System.err.println("Killing the Jenkins process as requested"); + _proc.destroyForcibly(); + } + } + /** * Runs one or more steps on the remote system. * (Compared to multiple calls, passing a series of steps is slightly more efficient