From bc05bb330c02b971a6baccbdcb2e0e6346a33f58 Mon Sep 17 00:00:00 2001 From: Eugene Lugovtsov <34510252+EugeneLugovtsov@users.noreply.github.com> Date: Fri, 10 Dec 2021 12:06:43 +0200 Subject: [PATCH] fix s3upload verbose param --- .../de/taimos/pipeline/aws/S3UploadStep.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/taimos/pipeline/aws/S3UploadStep.java b/src/main/java/de/taimos/pipeline/aws/S3UploadStep.java index fd9bf36..fa835ee 100644 --- a/src/main/java/de/taimos/pipeline/aws/S3UploadStep.java +++ b/src/main/java/de/taimos/pipeline/aws/S3UploadStep.java @@ -460,7 +460,7 @@ public String run() throws Exception { throw new FileNotFoundException(child.toURI().toString()); } - child.act(new RemoteUploader(Execution.this.step.createS3ClientOptions(), Execution.this.getContext().get(EnvVars.class), listener, bucket, path, metadatas, tags, acl, cacheControl, contentEncoding, contentType, contentDisposition, kmsId, sseAlgorithm, redirectLocation)); + child.act(new RemoteUploader(Execution.this.step.createS3ClientOptions(), Execution.this.getContext().get(EnvVars.class), listener, bucket, path, metadatas, tags, acl, cacheControl, contentEncoding, contentType, contentDisposition, kmsId, sseAlgorithm, redirectLocation, verbose)); listener.getLogger().println("Upload complete"); return String.format("s3://%s/%s", bucket, path); @@ -470,7 +470,7 @@ public String run() throws Exception { for (FilePath child : children) { fileList.add(child.act(FIND_FILE_ON_SLAVE)); } - dir.act(new RemoteListUploader(Execution.this.step.createS3ClientOptions(), Execution.this.getContext().get(EnvVars.class), listener, fileList, bucket, path, metadatas, tags, acl, cacheControl, contentEncoding, contentType, contentDisposition, kmsId, sseAlgorithm)); + dir.act(new RemoteListUploader(Execution.this.step.createS3ClientOptions(), Execution.this.getContext().get(EnvVars.class), listener, fileList, bucket, path, metadatas, tags, acl, cacheControl, contentEncoding, contentType, contentDisposition, kmsId, sseAlgorithm, verbose)); listener.getLogger().println("Upload complete"); return String.format("s3://%s/%s", bucket, path); } @@ -496,8 +496,9 @@ private static class RemoteUploader extends MasterToSlaveFileCallable { private final String kmsId; private final String sseAlgorithm; private final String redirectLocation; + private final boolean verbose; - RemoteUploader(S3ClientOptions amazonS3ClientOptions, EnvVars envVars, TaskListener taskListener, String bucket, String path, Map metadatas, Map tags, CannedAccessControlList acl, String cacheControl, String contentEncoding, String contentType, String contentDisposition, String kmsId, String sseAlgorithm, String redirectLocation) { + RemoteUploader(S3ClientOptions amazonS3ClientOptions, EnvVars envVars, TaskListener taskListener, String bucket, String path, Map metadatas, Map tags, CannedAccessControlList acl, String cacheControl, String contentEncoding, String contentType, String contentDisposition, String kmsId, String sseAlgorithm, String redirectLocation, boolean verbose) { this.amazonS3ClientOptions = amazonS3ClientOptions; this.envVars = envVars; this.taskListener = taskListener; @@ -513,6 +514,7 @@ private static class RemoteUploader extends MasterToSlaveFileCallable { this.kmsId = kmsId; this.sseAlgorithm = sseAlgorithm; this.redirectLocation = redirectLocation; + this.verbose = verbose; } @Override @@ -577,7 +579,9 @@ public Void invoke(File localFile, VirtualChannel channel) throws IOException, I final Upload upload = mgr.upload(request); upload.addProgressListener((ProgressListener) progressEvent -> { if (progressEvent.getEventType() == ProgressEventType.TRANSFER_COMPLETED_EVENT) { - RemoteUploader.this.taskListener.getLogger().println("Finished: " + upload.getDescription()); + if (this.verbose) { + RemoteUploader.this.taskListener.getLogger().println("Finished: " + upload.getDescription()); + } } }); upload.waitForCompletion(); @@ -638,7 +642,9 @@ public Void invoke(File localFile, VirtualChannel channel) throws IOException, I for (final Upload upload : fileUpload.getSubTransfers()) { upload.addProgressListener((ProgressListener) progressEvent -> { if (progressEvent.getEventType() == ProgressEventType.TRANSFER_COMPLETED_EVENT) { - RemoteUploader.this.taskListener.getLogger().println("Finished: " + upload.getDescription()); + if (this.verbose) { + RemoteUploader.this.taskListener.getLogger().println("Finished: " + upload.getDescription()); + } } }); } @@ -672,8 +678,9 @@ private static class RemoteListUploader extends MasterToSlaveFileCallable private final String contentDisposition; private final String kmsId; private final String sseAlgorithm; + private final boolean verbose; - RemoteListUploader(S3ClientOptions amazonS3ClientOptions, EnvVars envVars, TaskListener taskListener, List fileList, String bucket, String path, Map metadatas, Map tags, CannedAccessControlList acl, final String cacheControl, final String contentEncoding, final String contentType, final String contentDisposition, String kmsId, String sseAlgorithm) { + RemoteListUploader(S3ClientOptions amazonS3ClientOptions, EnvVars envVars, TaskListener taskListener, List fileList, String bucket, String path, Map metadatas, Map tags, CannedAccessControlList acl, final String cacheControl, final String contentEncoding, final String contentType, final String contentDisposition, String kmsId, String sseAlgorithm, boolean verbose) { this.amazonS3ClientOptions = amazonS3ClientOptions; this.envVars = envVars; this.taskListener = taskListener; @@ -689,6 +696,7 @@ private static class RemoteListUploader extends MasterToSlaveFileCallable this.contentDisposition = contentDisposition; this.kmsId = kmsId; this.sseAlgorithm = sseAlgorithm; + this.verbose = verbose; } @Override @@ -750,7 +758,9 @@ public Void invoke(File localFile, VirtualChannel channel) throws IOException, I for (final Upload upload : fileUpload.getSubTransfers()) { upload.addProgressListener((ProgressListener) progressEvent -> { if (progressEvent.getEventType() == ProgressEventType.TRANSFER_COMPLETED_EVENT) { - RemoteListUploader.this.taskListener.getLogger().println("Finished: " + upload.getDescription()); + if (this.verbose) { + RemoteListUploader.this.taskListener.getLogger().println("Finished: " + upload.getDescription()); + } } }); }