提交 a4ddfa7e 编写于 作者: O Olivier Lamy

Merge pull request #468 from Vlatombe/namespace-tools-installations-by-tool-name

Namespace tools installation by tool name.
Thanks!
......@@ -32,6 +32,8 @@ import jenkins.model.Jenkins;
import hudson.model.Label;
import hudson.model.Node;
import hudson.model.TaskListener;
import java.io.File;
import java.io.IOException;
import org.kohsuke.stapler.DataBoundConstructor;
......@@ -102,7 +104,7 @@ public abstract class ToolInstaller implements Describable<ToolInstaller>, Exten
* @param tool the tool being installed
* @param node the computer on which to install the tool
* @return {@link ToolInstallation#getHome} if specified, else a path within the local
* Hudson work area named according to {@link ToolInstallation#getName}
* Jenkins work area named according to {@link ToolInstallation#getName}
* @since 1.310
*/
protected final FilePath preferredLocation(ToolInstallation tool, Node node) {
......@@ -111,8 +113,7 @@ public abstract class ToolInstaller implements Describable<ToolInstaller>, Exten
}
String home = Util.fixEmptyAndTrim(tool.getHome());
if (home == null) {
// XXX should this somehow uniquify paths among ToolInstallation.all()?
home = tool.getName().replaceAll("[^A-Za-z0-9_.-]+", "_");
home = sanitize(tool.getDescriptor().getDisplayName()) + File.separatorChar + sanitize(tool.getName());
}
FilePath root = node.getRootPath();
if (root == null) {
......@@ -121,6 +122,10 @@ public abstract class ToolInstaller implements Describable<ToolInstaller>, Exten
return root.child("tools").child(home);
}
private String sanitize(String s) {
return s != null ? s.replaceAll("[^A-Za-z0-9_.-]+", "_") : null;
}
public ToolInstallerDescriptor<?> getDescriptor() {
return (ToolInstallerDescriptor) Jenkins.getInstance().getDescriptorOrDie(getClass());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册