Commit bbbeddc9 authored by mantou's avatar mantou

add one local with multiple remotes support

parent e9fc426d
...@@ -92,24 +92,28 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep { ...@@ -92,24 +92,28 @@ public class OSSPublisher extends Publisher implements SimpleBuildStep {
PrintStream logger = listener.getLogger(); PrintStream logger = listener.getLogger();
EnvVars envVars = run.getEnvironment(listener); EnvVars envVars = run.getEnvironment(listener);
OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret.getPlainText()); OSSClient client = new OSSClient(endpoint, accessKeyId, accessKeySecret.getPlainText());
String local = localPath.substring(1); String local = localPath.substring(1);
String remote = remotePath.substring(1);
String[] remotes = remotePath.split(",");
String expandLocal = envVars.expand(local); for (String remote : remotes) {
String expandRemote = envVars.expand(remote); remote = remote.substring(1);
logger.println("expandLocalPath =>" + expandLocal); String expandLocal = envVars.expand(local);
logger.println("expandRemotePath =>" + expandRemote); String expandRemote = envVars.expand(remote);
FilePath p = new FilePath(workspace, expandLocal); logger.println("expandLocalPath =>" + expandLocal);
if (p.isDirectory()) { logger.println("expandRemotePath =>" + expandRemote);
logger.println("upload dir => " + p); FilePath p = new FilePath(workspace, expandLocal);
upload(client, logger, expandRemote, p, true); if (p.isDirectory()) {
logger.println("upload dir success"); logger.println("upload dir => " + p);
} else { upload(client, logger, expandRemote, p, true);
logger.println("upload file => " + p); logger.println("upload dir success");
uploadFile(client, logger, expandRemote, p); } else {
logger.println("upload file success"); logger.println("upload file => " + p);
uploadFile(client, logger, expandRemote, p);
logger.println("upload file success");
}
} }
} }
private void upload(OSSClient client, PrintStream logger, String base, FilePath path, boolean root) private void upload(OSSClient client, PrintStream logger, String base, FilePath path, boolean root)
......
<div> <div>
Remote file or directory, must begin with `/` Remote file or directory, must begin with `/`,
one local with multiple remotes distination require,pass "," for each remote path
</div> </div>
\ No newline at end of file
<div> <div>
远程路径,必须以`/`开头 远程路径,必须以`/`开头
如果有本地单文件(目录),远程多文件(目录)需求,请使用","进行远程路径分隔.
</div> </div>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment