use of com.amazonaws.services.cloudformation.model.DescribeStackEventsResult in project pipeline-aws-plugin by jenkinsci.
the class EventPrinter method waitAndPrintEvents.
private void waitAndPrintEvents(String stack, long pollIntervalMillis, BasicFuture<AmazonWebServiceRequest> waitResult) throws ExecutionException {
Date startDate = new Date();
String lastEventId = null;
this.printLine();
this.printStackName(stack);
this.printLine();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
if (pollIntervalMillis > 0) {
while (!waitResult.isDone()) {
try {
DescribeStackEventsResult result = this.client.describeStackEvents(new DescribeStackEventsRequest().withStackName(stack));
List<StackEvent> stackEvents = new ArrayList<>();
for (StackEvent event : result.getStackEvents()) {
if (event.getEventId().equals(lastEventId) || event.getTimestamp().before(startDate)) {
break;
}
stackEvents.add(event);
}
if (!stackEvents.isEmpty()) {
Collections.reverse(stackEvents);
for (StackEvent event : stackEvents) {
this.printEvent(sdf, event);
this.printLine();
}
lastEventId = stackEvents.get(stackEvents.size() - 1).getEventId();
}
} catch (AmazonCloudFormationException e) {
// suppress and continue
}
try {
Thread.sleep(pollIntervalMillis);
} catch (InterruptedException e) {
// suppress and continue
}
}
}
try {
waitResult.get();
} catch (InterruptedException e) {
this.listener.getLogger().format("Failed to wait for CFN action to complete: %s", e.getMessage());
}
}
Aggregations