Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use list instead of string for ProcessBuilder For External Deletion Tools #13

Merged
merged 1 commit into from
Oct 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/hudson/plugins/ws_cleanup/Cleanup.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ public Object invoke(File f, VirtualChannel channel) throws IOException, Interru
if (delete_command != null && patterns == null) {
temp_command = delete_command.replaceAll("%s", "\"" + StringEscapeUtils.escapeJava(f.getPath()) + "\"");
this.listener.getLogger().println("Using command: " + temp_command);
Process deletion_proc = new ProcessBuilder(temp_command).start();
List<String> list = new ArrayList<String>();

java.util.regex.Pattern p = java.util.regex.Pattern.compile("\"[^\"]+\"|\\S+");
java.util.regex.Matcher m = p.matcher(temp_command);

while(m.find()) {
list.add(m.group());
}

Process deletion_proc = new ProcessBuilder(list).start();
deletion_proc.waitFor();

return null;
Expand Down