Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 24785d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions core/src/main/java/hudson/cli/DeleteNodeCommand.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
Expand Up @@ -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 {
Expand Down

0 comments on commit 24785d5

Please sign in to comment.