Example usage for com.amazonaws.services.codedeploy.model AutoRollbackEvent DEPLOYMENT_STOP_ON_ALARM

List of usage examples for com.amazonaws.services.codedeploy.model AutoRollbackEvent DEPLOYMENT_STOP_ON_ALARM

Introduction

In this page you can find the example usage for com.amazonaws.services.codedeploy.model AutoRollbackEvent DEPLOYMENT_STOP_ON_ALARM.

Prototype

AutoRollbackEvent DEPLOYMENT_STOP_ON_ALARM

To view the source code for com.amazonaws.services.codedeploy.model AutoRollbackEvent DEPLOYMENT_STOP_ON_ALARM.

Click Source Link

Usage

From source file:jetbrains.buildServer.runner.codedeploy.AWSClient.java

License:Apache License

@NotNull
private String createDeployment(@NotNull RevisionLocation revisionLocation, @NotNull String applicationName,
        @NotNull String deploymentGroupName, @NotNull Map<String, String> ec2Tags,
        @NotNull Collection<String> autoScalingGroups, @Nullable String deploymentConfigName,
        boolean rollbackOnFailure, boolean rollbackOnAlarmThreshold) {
    myListener.createDeploymentStarted(applicationName, deploymentGroupName, deploymentConfigName);

    final CreateDeploymentRequest request = new CreateDeploymentRequest().withRevision(revisionLocation)
            .withApplicationName(applicationName).withDeploymentGroupName(deploymentGroupName)
            .withDescription(getDescription("Deployment created by ", 100));

    if (StringUtil.isNotEmpty(deploymentConfigName))
        request.setDeploymentConfigName(deploymentConfigName);
    if (!ec2Tags.isEmpty() || !autoScalingGroups.isEmpty()) {
        request.withTargetInstances(new TargetInstances().withTagFilters(getTagFilters(ec2Tags))
                .withAutoScalingGroups(autoScalingGroups));
    }/*ww w.jav  a2 s .c om*/
    if (rollbackOnFailure || rollbackOnAlarmThreshold) {
        final AutoRollbackConfiguration rollbackConfiguration = new AutoRollbackConfiguration()
                .withEnabled(true);
        if (rollbackOnFailure) {
            rollbackConfiguration.withEvents(AutoRollbackEvent.DEPLOYMENT_FAILURE);
        }
        if (rollbackOnAlarmThreshold) {
            rollbackConfiguration.withEvents(AutoRollbackEvent.DEPLOYMENT_STOP_ON_ALARM);
        }
        request.setAutoRollbackConfiguration(rollbackConfiguration);
    }

    final String deploymentId = myCodeDeployClient.createDeployment(request).getDeploymentId();
    myListener.createDeploymentFinished(applicationName, deploymentGroupName, deploymentConfigName,
            deploymentId);
    return deploymentId;
}