From ef82068bd6c9dfba1c6b32c125151f4b939e282b Mon Sep 17 00:00:00 2001 From: Qingyang Chen Date: Tue, 11 Dec 2018 18:59:42 -0500 Subject: [PATCH] Adds SuccessEvent. --- .../cloud/tools/jib/event/JibEventType.java | 4 ++++ .../tools/jib/event/events/SuccessEvent.java | 22 +++++++++++++++++++ .../jib/plugins/common/BuildStepsRunner.java | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 jib-core/src/main/java/com/google/cloud/tools/jib/event/events/SuccessEvent.java diff --git a/jib-core/src/main/java/com/google/cloud/tools/jib/event/JibEventType.java b/jib-core/src/main/java/com/google/cloud/tools/jib/event/JibEventType.java index 6f9c47dae7..f9eea5b199 100644 --- a/jib-core/src/main/java/com/google/cloud/tools/jib/event/JibEventType.java +++ b/jib-core/src/main/java/com/google/cloud/tools/jib/event/JibEventType.java @@ -18,6 +18,7 @@ import com.google.cloud.tools.jib.event.events.LogEvent; import com.google.cloud.tools.jib.event.events.ProgressEvent; +import com.google.cloud.tools.jib.event.events.SuccessEvent; import com.google.cloud.tools.jib.event.events.TimerEvent; import com.google.common.annotations.VisibleForTesting; @@ -40,6 +41,9 @@ public class JibEventType { public static final JibEventType PROGRESS = new JibEventType<>(ProgressEvent.class); + /** Event indicating successful build completion. */ + public static final JibEventType SUCCESS = new JibEventType<>(SuccessEvent.class); + // TODO: Add entries for all JibEvent types. private final Class eventClass; diff --git a/jib-core/src/main/java/com/google/cloud/tools/jib/event/events/SuccessEvent.java b/jib-core/src/main/java/com/google/cloud/tools/jib/event/events/SuccessEvent.java new file mode 100644 index 0000000000..7895b7b802 --- /dev/null +++ b/jib-core/src/main/java/com/google/cloud/tools/jib/event/events/SuccessEvent.java @@ -0,0 +1,22 @@ +/* + * Copyright 2018 Google LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.cloud.tools.jib.event.events; + +import com.google.cloud.tools.jib.event.JibEvent; + +/** Indicates build success. */ +public class SuccessEvent implements JibEvent {} diff --git a/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/BuildStepsRunner.java b/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/BuildStepsRunner.java index 64e1658404..d3149c555d 100644 --- a/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/BuildStepsRunner.java +++ b/jib-plugins-common/src/main/java/com/google/cloud/tools/jib/plugins/common/BuildStepsRunner.java @@ -26,6 +26,7 @@ import com.google.cloud.tools.jib.configuration.LayerConfiguration; import com.google.cloud.tools.jib.event.EventDispatcher; import com.google.cloud.tools.jib.event.events.LogEvent; +import com.google.cloud.tools.jib.event.events.SuccessEvent; import com.google.cloud.tools.jib.image.ImageReference; import com.google.cloud.tools.jib.image.LayerEntry; import com.google.cloud.tools.jib.registry.InsecureRegistryException; @@ -213,6 +214,7 @@ public JibContainer build( eventDispatcher.dispatch(LogEvent.lifecycle("")); eventDispatcher.dispatch(LogEvent.lifecycle(successMessage)); + eventDispatcher.dispatch(new SuccessEvent()); // when an image is built, write out the digest and id if (imageDigestOutputPath != null) {