Skip to content

Commit a9d330e

Browse files
author
Wagner Spirigoni
committed
test
1 parent a52bb67 commit a9d330e

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</parent>
88

99
<artifactId>codedeploy</artifactId>
10-
<version>1.11</version>
10+
<version>1.12</version>
1111
<packaging>hpi</packaging>
1212
<groupId>com.amazonaws</groupId>
1313
<name>AWS CodeDeploy Plugin for Jenkins</name>

src/main/java/com/amazonaws/codedeploy/AWSCodeDeployPublisher.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
import java.io.File;
5959
import java.io.FileOutputStream;
60+
import java.io.FileReader;
6061
import java.io.IOException;
6162
import java.io.PrintStream;
6263
import java.util.Date;
@@ -101,6 +102,7 @@ public class AWSCodeDeployPublisher extends Publisher {
101102
private final String awsSecretKey;
102103
private final String credentials;
103104
private final String deploymentMethod;
105+
private final String versionFileName;
104106

105107
private PrintStream logger;
106108
private Map <String, String> envVars;
@@ -118,6 +120,7 @@ public AWSCodeDeployPublisher(
118120
Long pollingTimeoutSec,
119121
Long pollingFreqSec,
120122
String credentials,
123+
String versionFileName,
121124
String deploymentMethod,
122125
String awsAccessKey,
123126
String awsSecretKey,
@@ -145,6 +148,7 @@ public AWSCodeDeployPublisher(
145148
this.proxyPort = proxyPort;
146149
this.credentials = credentials;
147150
this.deploymentMethod = deploymentMethod;
151+
this.versionFileName = versionFileName;
148152
this.awsAccessKey = awsAccessKey;
149153
this.awsSecretKey = awsSecretKey;
150154
this.iamRoleArn = iamRoleArn;
@@ -336,13 +340,35 @@ private RevisionLocation zipAndUpload(AWSClients aws, String projectName, FilePa
336340
logger.println("Uploading zip to s3://" + bucket + "/" + key);
337341
PutObjectResult s3result = aws.s3.putObject(bucket, key, zipFile);
338342

343+
File versionFile;
344+
versionFile = new File(sourceDirectory + "/" + versionFileName);
345+
346+
FileReader reader = null;
347+
String version = null;
348+
try {
349+
reader = new FileReader(versionFile);
350+
char[] chars = new char[(int) versionFile.length()];
351+
reader.read(chars);
352+
version = new String(chars);
353+
reader.close();
354+
} catch (IOException e) {
355+
e.printStackTrace();
356+
} finally {
357+
if(reader !=null){reader.close();}
358+
}
339359

340360
S3Location s3Location = new S3Location();
341361
s3Location.setBucket(bucket);
342362
s3Location.setKey(key);
343363
s3Location.setBundleType(BundleType.Zip);
344364
s3Location.setETag(s3result.getETag());
345365

366+
if (version != null){
367+
s3Location.setVersion(version);
368+
}
369+
370+
371+
346372
RevisionLocation revisionLocation = new RevisionLocation();
347373
revisionLocation.setRevisionType(RevisionLocationType.S3);
348374
revisionLocation.setS3Location(s3Location);
@@ -645,6 +671,10 @@ public String getDeploymentMethod() {
645671
return deploymentMethod;
646672
}
647673

674+
public String getVersionFileName() {
675+
return versionFileName;
676+
}
677+
648678
public boolean getWaitForCompletion() {
649679
return waitForCompletion;
650680
}

src/main/resources/com/amazonaws/codedeploy/AWSCodeDeployPublisher/config.jelly

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
<f:entry title="Proxy Host" field="proxyHost">
3030
<f:textbox default="" />
3131
</f:entry>
32-
<f:entry title="Proxy Port" field="proxyPort">
32+
<f:entry title="Proxy Port" field="proxyPort">
3333
<f:textbox default="" />
3434
</f:entry>
35+
<f:entry title="Version File" field="versionFileName">
36+
<f:textbox />
37+
</f:entry>
3538

3639
<f:entry title="Appspec.yml per Deployment Group" field="deploymentGroupAppspec">
3740
<f:checkbox field="deploymentGroupAppspec" checked="${instance.getDeploymentGroupAppspec}"/>

0 commit comments

Comments
 (0)