diff --git a/src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java b/src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java index e39fe9e..5f7b77d 100644 --- a/src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java +++ b/src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java @@ -107,6 +107,7 @@ public class AWSCodeDeployPublisher extends Publisher implements SimpleBuildStep private final String awsSecretKey; private final String credentials; private final String deploymentMethod; + private final String zipNamePrefix; private final String versionFileName; private PrintStream logger; @@ -127,6 +128,7 @@ public AWSCodeDeployPublisher( Long pollingTimeoutSec, Long pollingFreqSec, String credentials, + String zipNamePrefix, String versionFileName, String deploymentMethod, String awsAccessKey, @@ -155,6 +157,7 @@ public AWSCodeDeployPublisher( this.proxyPort = proxyPort; this.credentials = credentials; this.deploymentMethod = deploymentMethod; + this.zipNamePrefix = zipNamePrefix; this.versionFileName = versionFileName; this.awsAccessKey = awsAccessKey; this.awsSecretKey = awsSecretKey; @@ -230,7 +233,14 @@ public void perform(@Nonnull Run build, @Nonnull FilePath workspace, @Nonnu verifyCodeDeployApplication(aws); - final String projectName = build.getDisplayName(); + String projectName = null; + logger.println("Zip name prefix: " + this.zipNamePrefix ); + if (this.zipNamePrefix != null && this.zipNamePrefix.trim().length() > 0) { + projectName = build.getEnvironment(listener).expand(zipNamePrefix.trim()); + } else { + projectName = build.getDisplayName(); + } + if (workspace == null) { throw new IllegalArgumentException("No workspace present for the build."); } @@ -317,6 +327,8 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa File versionFile; versionFile = new File(sourceDirectory + "/" + versionFileName); + logger.println("Project name: " + projectName + " - Version file path : " + versionFile.getAbsolutePath() + " - Version filename : " + versionFileName); + InputStreamReader reader = null; String version = null; try { @@ -332,7 +344,9 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa } if (version != null){ - zipFile = new File("/tmp/" + projectName + "-" + version + ".zip"); + String tempDir = System.getProperty("java.io.tmpdir"); + + zipFile = new File(tempDir + File.separator + projectName + "-" + version + ".zip"); final boolean fileCreated = zipFile.createNewFile(); if (!fileCreated) { logger.println("File already exists, overwriting: " + zipFile.getPath()); @@ -713,6 +727,10 @@ public String getDeploymentMethod() { return deploymentMethod; } + public String getZipNamePrefix() { + return zipNamePrefix; + } + public String getVersionFileName() { return versionFileName; } diff --git a/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/config.jelly b/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/config.jelly index d3ba81d..2b5fe3a 100644 --- a/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/config.jelly +++ b/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/config.jelly @@ -39,6 +39,9 @@ + + + diff --git a/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/help-versionFileName.html b/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/help-versionFileName.html new file mode 100644 index 0000000..07b13f2 --- /dev/null +++ b/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/help-versionFileName.html @@ -0,0 +1,11 @@ +
+ The path to a version file name relative to the subdirectory. The file must contain a version of the application. + If Version file name is set the name of the zip uploaded to S3 will be : + build display name + "-" + version.zip + Or + Zip prefix name + "-" + version.zip + If not set, the name will be + build display name + "-" + generated uid.zip + Or + Zip prefix name + "-" + generated uid.zip +
diff --git a/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/help-zipNamePrefix.html b/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/help-zipNamePrefix.html new file mode 100644 index 0000000..909dc72 --- /dev/null +++ b/src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/help-zipNamePrefix.html @@ -0,0 +1,3 @@ +
+ The prefix of the name of the zip you wish to deploy to S3. If none is set the display name of the build (ex: #3) will be use. +