From ea42fae061629305ce005a999faacc4e5e1306bc Mon Sep 17 00:00:00 2001 From: Evandro Silvestre Date: Mon, 14 Sep 2015 15:12:29 -0300 Subject: [PATCH 1/3] Add a field for destination file name on S3 --- src/main/java/hudson/plugins/s3/Entry.java | 10 +++++++++- .../java/hudson/plugins/s3/S3BucketPublisher.java | 4 ++-- src/main/java/hudson/plugins/s3/S3Profile.java | 14 +++++++++----- .../resources/hudson/plugins/s3/Entry/config.jelly | 3 +++ .../hudson/plugins/s3/Entry/help-bucket.html | 3 +-- .../plugins/s3/Entry/help-destinationFile.html | 2 ++ 6 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html diff --git a/src/main/java/hudson/plugins/s3/Entry.java b/src/main/java/hudson/plugins/s3/Entry.java index 65ee36d3..647e7374 100644 --- a/src/main/java/hudson/plugins/s3/Entry.java +++ b/src/main/java/hudson/plugins/s3/Entry.java @@ -18,6 +18,13 @@ public final class Entry implements Describable { * Can contain macros and wildcards. */ public String sourceFile; + + /** + * File name in the S3 + * This is optional + */ + public String destinationFile; + /** * options for x-amz-storage-class can be STANDARD or REDUCED_REDUNDANCY */ @@ -61,11 +68,12 @@ public final class Entry implements Describable { public boolean flatten; @DataBoundConstructor - public Entry(String bucket, String sourceFile, String storageClass, String selectedRegion, + public Entry(String bucket, String sourceFile, String destinationFile, String storageClass, String selectedRegion, boolean noUploadOnFailure, boolean uploadFromSlave, boolean managedArtifacts, boolean useServerSideEncryption, boolean flatten) { this.bucket = bucket; this.sourceFile = sourceFile; + this.destinationFile = destinationFile; this.storageClass = storageClass; this.selectedRegion = selectedRegion; this.noUploadOnFailure = noUploadOnFailure; diff --git a/src/main/java/hudson/plugins/s3/S3BucketPublisher.java b/src/main/java/hudson/plugins/s3/S3BucketPublisher.java index 273c871c..358a71bd 100644 --- a/src/main/java/hudson/plugins/s3/S3BucketPublisher.java +++ b/src/main/java/hudson/plugins/s3/S3BucketPublisher.java @@ -178,8 +178,8 @@ public boolean perform(AbstractBuild build, List records = Lists.newArrayList(); for (FilePath src : paths) { - log(listener.getLogger(), "bucket=" + bucket + ", file=" + src.getName() + " region=" + selRegion + ", upload from slave=" + entry.uploadFromSlave + " managed="+ entry.managedArtifacts + " , server encryption "+entry.useServerSideEncryption); - records.add(profile.upload(build, listener, bucket, src, searchPathLength, escapedUserMetadata, storageClass, selRegion, entry.uploadFromSlave, entry.managedArtifacts, entry.useServerSideEncryption, entry.flatten)); + log(listener.getLogger(), "bucket=" + bucket + ", file=" + src.getName() + " destination: " + entry.destinationFile + " region=" + selRegion + ", upload from slave=" + entry.uploadFromSlave + " managed="+ entry.managedArtifacts + " , server encryption "+entry.useServerSideEncryption); + records.add(profile.upload(build, listener, bucket, entry.destinationFile, src, searchPathLength, escapedUserMetadata, storageClass, selRegion, entry.uploadFromSlave, entry.managedArtifacts, entry.useServerSideEncryption, entry.flatten)); } if (entry.managedArtifacts) { artifacts.addAll(records); diff --git a/src/main/java/hudson/plugins/s3/S3Profile.java b/src/main/java/hudson/plugins/s3/S3Profile.java index 6375be71..f364005f 100644 --- a/src/main/java/hudson/plugins/s3/S3Profile.java +++ b/src/main/java/hudson/plugins/s3/S3Profile.java @@ -166,18 +166,22 @@ public void check() throws Exception { getClient().listBuckets(); } - public FingerprintRecord upload(AbstractBuild build, final BuildListener listener, String bucketName, FilePath filePath, int searchPathLength, List userMetadata, + public FingerprintRecord upload(AbstractBuild build, final BuildListener listener, String bucketName, String destinationFile, FilePath filePath, int searchPathLength, List userMetadata, String storageClass, String selregion, boolean uploadFromSlave, boolean managedArtifacts,boolean useServerSideEncryption, boolean flatten) throws IOException, InterruptedException { if (filePath.isDirectory()) { throw new IOException(filePath + " is a directory"); } String fileName = null; - if (flatten) { - fileName = filePath.getName(); + if (destinationFile == null){ + if (flatten) { + fileName = filePath.getName(); + } else { + String relativeFileName = filePath.getRemote(); + fileName = relativeFileName.substring(searchPathLength); + } } else { - String relativeFileName = filePath.getRemote(); - fileName = relativeFileName.substring(searchPathLength); + fileName = destinationFile; } Destination dest = new Destination(bucketName, fileName); diff --git a/src/main/resources/hudson/plugins/s3/Entry/config.jelly b/src/main/resources/hudson/plugins/s3/Entry/config.jelly index 1978cdee..3915d1ae 100644 --- a/src/main/resources/hudson/plugins/s3/Entry/config.jelly +++ b/src/main/resources/hudson/plugins/s3/Entry/config.jelly @@ -6,6 +6,9 @@ + + + diff --git a/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html b/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html index 14069ab6..32ecdc66 100644 --- a/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html +++ b/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html @@ -1,2 +1 @@ -
Destination bucket. It will be created if doesn't exist. Environment variable can be used, for example -my-artifact-bucket/${JOB_NAME}-${BUILD_NUMBER}
+
Destination file name. This property is optional
diff --git a/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html b/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html new file mode 100644 index 00000000..14069ab6 --- /dev/null +++ b/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html @@ -0,0 +1,2 @@ +
Destination bucket. It will be created if doesn't exist. Environment variable can be used, for example +my-artifact-bucket/${JOB_NAME}-${BUILD_NUMBER}
From 69b0af54ba595d2ebc27452cf1256fc77365dcbb Mon Sep 17 00:00:00 2001 From: Evandro Silvestre Date: Mon, 14 Sep 2015 15:14:24 -0300 Subject: [PATCH 2/3] Add a field for destination file name on S3 --- src/main/resources/hudson/plugins/s3/Entry/help-bucket.html | 3 ++- .../hudson/plugins/s3/Entry/help-destinationFile.html | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html b/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html index 32ecdc66..14069ab6 100644 --- a/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html +++ b/src/main/resources/hudson/plugins/s3/Entry/help-bucket.html @@ -1 +1,2 @@ -
Destination file name. This property is optional
+
Destination bucket. It will be created if doesn't exist. Environment variable can be used, for example +my-artifact-bucket/${JOB_NAME}-${BUILD_NUMBER}
diff --git a/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html b/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html index 14069ab6..32ecdc66 100644 --- a/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html +++ b/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html @@ -1,2 +1 @@ -
Destination bucket. It will be created if doesn't exist. Environment variable can be used, for example -my-artifact-bucket/${JOB_NAME}-${BUILD_NUMBER}
+
Destination file name. This property is optional
From 9fc5b9c165e5dbcffce24241f585dcb689872fb0 Mon Sep 17 00:00:00 2001 From: Carlos Alberto Viana Pitondo <137213594+carlos-pitondo-geo@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:44:14 -0300 Subject: [PATCH 3/3] Create CODEOWNERS --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..418d49b1 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @geofusion/techleads