Skip to content

Commit f593721

Browse files
authored
Merge branch 'master' into master
2 parents d12fbdc + 6e89299 commit f593721

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,30 @@ ebWaitOnEnvironmentHealth(
10991099

11001100
## current master
11011101

1102+
## 1.45
1103+
### Enhanced ECS and Lambda Deployment Support
1104+
1105+
We've improved the `CreateDeployStep` class to better handle ECS and Lambda deployments:
1106+
1107+
1. Added a new method `isEcsOrLambdaDeployment()` to detect if the deployment is for ECS or Lambda.
1108+
2. Modified the `getFileExistsBehavior()` method to skip setting `FileExistsBehavior` for ECS and Lambda deployments.
1109+
3. These changes ensure that the `fileExistsBehavior` parameter is only set for EC2/On-premises deployments, avoiding potential issues with ECS and Lambda deployments.
1110+
1111+
### New Dependencies
1112+
1113+
The following new imports have been added to support these changes:
1114+
1115+
- `com.amazonaws.services.codedeploy.model.GetDeploymentGroupRequest`
1116+
- `com.amazonaws.services.codedeploy.model.GetDeploymentGroupResult`
1117+
- `com.amazonaws.services.codedeploy.model.DeploymentGroupInfo`
1118+
1119+
### Improved Error Handling
1120+
1121+
The `isEcsOrLambdaDeployment()` method includes basic error handling to gracefully handle any exceptions that may occur when querying the deployment group information.
1122+
1123+
These updates enhance the plugin's compatibility with different AWS CodeDeploy compute platforms while maintaining existing functionality for EC2/On-premises deployments.
1124+
1125+
11021126
## 1.44
11031127
* Fix global configuration naming for JCasC. Please note that this is a breaking change if JCasC is defined. This can be fixed by renaming pluginImpl --> pipelineStepsAWS.
11041128
* Fix Elastic Beanstalk client creation bug that ignored provided configurations in the withAWSStep

pom.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<dependencies>
2323
<dependency>
2424
<groupId>io.jenkins.tools.bom</groupId>
25-
<artifactId>bom-2.414.x</artifactId>
25+
<artifactId>bom-${jenkins.baseline}.x</artifactId>
2626
<version>2928.ved44ea_84e034</version>
2727
<scope>import</scope>
2828
<type>pom</type>
@@ -78,7 +78,9 @@
7878
<properties>
7979
<revision>1.46</revision>
8080
<changelist>-SNAPSHOT</changelist>
81-
<jenkins.version>2.414.3</jenkins.version>
81+
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
82+
<jenkins.baseline>2.414</jenkins.baseline>
83+
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
8284
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
8385
</properties>
8486
<build>
@@ -254,4 +256,4 @@
254256

255257
</dependencies>
256258

257-
</project>
259+
</project>

src/main/java/de/taimos/pipeline/aws/code/deploy/CreateDeployStep.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import com.amazonaws.services.codedeploy.model.RevisionLocation;
1010
import com.amazonaws.services.codedeploy.model.RevisionLocationType;
1111
import com.amazonaws.services.codedeploy.model.S3Location;
12+
import com.amazonaws.services.codedeploy.model.GetDeploymentGroupRequest;
13+
import com.amazonaws.services.codedeploy.model.GetDeploymentGroupResult;
14+
import com.amazonaws.services.codedeploy.model.DeploymentGroupInfo;
1215
import de.taimos.pipeline.aws.AWSClientFactory;
1316
import de.taimos.pipeline.aws.utils.StepUtils;
1417
import hudson.Extension;
@@ -160,9 +163,13 @@ protected Void run() throws Exception {
160163
.withDeploymentConfigName(step.getDeploymentConfigName())
161164
.withDescription(step.getDescription())
162165
.withRevision(getRevisionLocation())
163-
.withFileExistsBehavior(getFileExistsBehavior(step.getFileExistsBehavior()))
164166
.withIgnoreApplicationStopFailures(step.getIgnoreApplicationStopFailures());
165167

168+
FileExistsBehavior fileExistsBehavior = getFileExistsBehavior(step.getFileExistsBehavior());
169+
if (fileExistsBehavior != null) {
170+
deploymentRequest.withFileExistsBehavior(fileExistsBehavior);
171+
}
172+
166173
CreateDeploymentResult deployment = client.createDeployment(deploymentRequest);
167174

168175
listener.getLogger().format("DeploymentId (%s) %n", deployment.getDeploymentId());
@@ -176,12 +183,36 @@ protected Void run() throws Exception {
176183
}
177184

178185
private FileExistsBehavior getFileExistsBehavior(String fileExistsBehavior) {
186+
if (isEcsOrLambdaDeployment()) {
187+
return null;
188+
}
179189
if (StringUtils.isEmpty(fileExistsBehavior)) {
180190
return FileExistsBehavior.DISALLOW;
181191
}
182192
return FileExistsBehavior.fromValue(fileExistsBehavior);
183193
}
184194

195+
private boolean isEcsOrLambdaDeployment() {
196+
AmazonCodeDeploy codeDeploy = AWSClientFactory.create(AmazonCodeDeployClientBuilder.standard(), this.getContext());
197+
198+
try {
199+
GetDeploymentGroupRequest request =
200+
new GetDeploymentGroupRequest()
201+
.withApplicationName(step.getApplicationName())
202+
.withDeploymentGroupName(step.getDeploymentGroupName());
203+
204+
GetDeploymentGroupResult response =
205+
codeDeploy.getDeploymentGroup(request);
206+
207+
String computePlatform = response.getDeploymentGroupInfo().getComputePlatform();
208+
209+
return "ECS".equalsIgnoreCase(computePlatform) || "Lambda".equalsIgnoreCase(computePlatform);
210+
} catch (Exception e) {
211+
// Log the exception or handle it as appropriate for your use case
212+
return false;
213+
}
214+
}
215+
185216
private RevisionLocation getRevisionLocation() {
186217
if (StringUtils.isNotEmpty(step.getS3Bucket())) {
187218
final S3Location s3Location = new S3Location().withBucket(step.getS3Bucket())
@@ -201,4 +232,4 @@ private RevisionLocation getRevisionLocation() {
201232
private static final long serialVersionUID = 1L;
202233

203234
}
204-
}
235+
}

0 commit comments

Comments
 (0)