Skip to content
Permalink
Browse files
[JENKINS-31098] Deletage remove a node back to Computer.doDoDelete()
(cherry picked from commit 04a874a)
  • Loading branch information
pjanouse authored and olivergondza committed Nov 24, 2015
1 parent a877ca6 commit 24785d545971e10ece89b29fa2dfb50c29c85fd9
Showing with 8 additions and 10 deletions.
  1. +7 −9 core/src/main/java/hudson/cli/DeleteNodeCommand.java
  2. +1 −1 test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
@@ -29,6 +29,7 @@
import jenkins.model.Jenkins;
import org.kohsuke.args4j.Argument;

import java.nio.file.AccessDeniedException;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Logger;
@@ -77,15 +78,12 @@ protected int run() throws Exception {
continue;
}

try {
node.checkPermission(Computer.DELETE);
} catch (Exception e) {
stderr.println(e.getMessage());
errorOccurred = true;
continue;
}

jenkins.removeNode(node);
node.toComputer().doDoDelete();
} catch (AccessDeniedException e) {
stderr.println(e.getMessage());
errorOccurred = true;
//noinspection UnnecessaryContinue
continue;
} catch (Exception e) {
final String errorMsg = String.format("Unexpected exception occurred during deletion of node '%s': %s",
node == null ? "(null)" : node.toComputer().getName(),
@@ -48,7 +48,7 @@ public class DeleteNodeCommandTest {

@Before public void setUp() {

command = new CLICommandInvoker(j, new DeleteNodeCommand());
command = new CLICommandInvoker(j, "delete-node");
}

@Test public void deleteNodeShouldFailWithoutNodeDeletePermission() throws Exception {

0 comments on commit 24785d5

Please sign in to comment.