Skip to content
Open
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
12 changes: 12 additions & 0 deletions src/main/java/hudson/plugins/ws_cleanup/RemoteCleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.slaves.EnvironmentVariablesNodeProperty;
import hudson.EnvVars;

import java.io.IOException;
import java.util.List;
Expand All @@ -47,6 +48,17 @@
TaskListener listener,
Run<?, ?> build
) {
try {
EnvVars vars = build.getEnvironment(listener);

for (int i = 0; i < patterns.size(); i++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patterns can be null here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Good point.

patterns.set(i, new Pattern(vars.expand(patterns.get(i).getPattern()), patterns.get(i).getType()));

@olivergondza olivergondza Sep 15, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Using VariableResolver will save some object instantiations here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, will take a look.

}
externalDelete = vars.expand(externalDelete);
} catch (Exception e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What failures do we expect here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was to satisfy an error that was thrown when using EnvVars vars = build.getEnvironment(listener); that complained there wasn't an exception catch.

e.printStackTrace(listener.getLogger());
}

boolean wipeout = (patterns == null || patterns.isEmpty())
&& (externalDelete == null || externalDelete.isEmpty())
;
Expand Down