diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 00000000..418d49b1 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @geofusion/techleads 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-destinationFile.html b/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html new file mode 100644 index 00000000..32ecdc66 --- /dev/null +++ b/src/main/resources/hudson/plugins/s3/Entry/help-destinationFile.html @@ -0,0 +1 @@ +
Destination file name. This property is optional