diff --git a/gitlab4j-api/src/main/java/org/gitlab4j/api/WebHookManager.java b/gitlab4j-api/src/main/java/org/gitlab4j/api/WebHookManager.java index 27439e35..a7c2311b 100644 --- a/gitlab4j-api/src/main/java/org/gitlab4j/api/WebHookManager.java +++ b/gitlab4j-api/src/main/java/org/gitlab4j/api/WebHookManager.java @@ -23,6 +23,7 @@ import org.gitlab4j.api.webhook.TagPushEvent; import org.gitlab4j.api.webhook.WebHookListener; import org.gitlab4j.api.webhook.WikiPageEvent; +import org.gitlab4j.api.webhook.WorkItemEvent; /** * This class provides a handler for processing GitLab WebHook callouts. @@ -186,6 +187,7 @@ public void handleEvent(Event event) throws GitLabApiException { case WikiPageEvent.OBJECT_KIND: case ReleaseEvent.OBJECT_KIND: case DeploymentEvent.OBJECT_KIND: + case WorkItemEvent.OBJECT_KIND: fireEvent(event); break; @@ -270,6 +272,10 @@ public void fireEvent(Event event) throws GitLabApiException { fireDeploymentEvent((DeploymentEvent) event); break; + case WorkItemEvent.OBJECT_KIND: + fireWorkItemEvent((WorkItemEvent) event); + break; + default: String message = "Unsupported event object_kind, object_kind=" + event.getObjectKind(); LOGGER.warning(message); @@ -337,6 +343,12 @@ protected void fireDeploymentEvent(DeploymentEvent deploymentEvent) { } } + protected void fireWorkItemEvent(WorkItemEvent workItemEvent) { + for (WebHookListener listener : webhookListeners) { + listener.onWorkItemEvent(workItemEvent); + } + } + protected void fireReleaseEvent(ReleaseEvent releaseEvent) { for (WebHookListener listener : webhookListeners) { listener.onReleaseEvent(releaseEvent); diff --git a/gitlab4j-models/src/main/java/org/gitlab4j/api/webhook/WebHookListener.java b/gitlab4j-models/src/main/java/org/gitlab4j/api/webhook/WebHookListener.java index a69da69d..93b61bdc 100644 --- a/gitlab4j-models/src/main/java/org/gitlab4j/api/webhook/WebHookListener.java +++ b/gitlab4j-models/src/main/java/org/gitlab4j/api/webhook/WebHookListener.java @@ -76,6 +76,13 @@ default void onWikiPageEvent(WikiPageEvent wikiEvent) {} */ default void onDeploymentEvent(DeploymentEvent deploymentEvent) {} + /** + * This method is called when a WebHook work item event has been received. + * + * @param workItemEvent the WorkItemEvent instance + */ + default void onWorkItemEvent(WorkItemEvent workItemEvent) {} + /** * This method is called when a WebHook release event has been received. *