Skip to content

Commit f7821d1

Browse files
committed
Ensure there are no Jenkins nodes remaining after the test
1 parent 50beed2 commit f7821d1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ public void allDead() throws Exception {
131131
for (int i = 0; i < 100 && r.isSomethingHappening(); i++) {
132132
Thread.sleep(100);
133133
}
134+
Jenkins.get().getNodes().stream()
135+
.filter(KubernetesSlave.class::isInstance)
136+
.map(KubernetesSlave.class::cast)
137+
.forEach(agent -> {
138+
LOGGER.info(() -> "Deleting remaining node " + agent);
139+
try {
140+
agent.terminate();
141+
} catch (InterruptedException | IOException e) {
142+
LOGGER.log(Level.WARNING, "Failed to terminate " + agent, e);
143+
}
144+
});
134145
}
135146

136147
@Issue("JENKINS-57993")

0 commit comments

Comments
 (0)