diff --git a/src/main/java/org/gitlab4j/api/models/Environment.java b/src/main/java/org/gitlab4j/api/models/Environment.java index 064037a8..36ca1c1f 100644 --- a/src/main/java/org/gitlab4j/api/models/Environment.java +++ b/src/main/java/org/gitlab4j/api/models/Environment.java @@ -1,6 +1,7 @@ package org.gitlab4j.api.models; import java.io.Serializable; +import java.util.Date; import org.gitlab4j.api.utils.JacksonJson; import org.gitlab4j.api.utils.JacksonJsonEnumHelper; @@ -41,6 +42,7 @@ public String toString() { private String tier; private EnvironmentState state; private Deployment lastDeployment; + private Date autoStopAt; public Long getId() { return id; @@ -98,6 +100,14 @@ public void setLastDeployment(Deployment lastDeployment) { this.lastDeployment = lastDeployment; } + public Date getAutoStopAt() { + return autoStopAt; + } + + public void setAutoStopAt(Date autoStopAt) { + this.autoStopAt = autoStopAt; + } + @Override public String toString() { return (JacksonJson.toJsonString(this)); diff --git a/src/main/java/org/gitlab4j/api/webhook/DeploymentEvent.java b/src/main/java/org/gitlab4j/api/webhook/DeploymentEvent.java index b1ba2a5d..b777ca21 100644 --- a/src/main/java/org/gitlab4j/api/webhook/DeploymentEvent.java +++ b/src/main/java/org/gitlab4j/api/webhook/DeploymentEvent.java @@ -12,6 +12,7 @@ public class DeploymentEvent extends AbstractEvent { private String status; private String statusChangedAt; private Long deployableId; + private Long deploymentId; private String deployableUrl; private String environment; private EventProject project; @@ -55,6 +56,14 @@ public void setDeployableId(Long deployableId) { this.deployableId = deployableId; } + public Long getDeploymentId() { + return deploymentId; + } + + public void setDeploymentId(Long deploymentId) { + this.deploymentId = deploymentId; + } + public String getDeployableUrl() { return deployableUrl; } diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java b/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java index 215fd797..7310b073 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java @@ -26,6 +26,7 @@ import org.gitlab4j.api.utils.JacksonJson; import org.gitlab4j.api.webhook.BuildEvent; import org.gitlab4j.api.webhook.ChangeContainer; +import org.gitlab4j.api.webhook.DeploymentEvent; import org.gitlab4j.api.webhook.Event; import org.gitlab4j.api.webhook.IssueEvent; import org.gitlab4j.api.webhook.JobEvent; @@ -65,6 +66,12 @@ public static void teardown() { GitLabApi.getLogger().setLevel(savedLevel); } + @Test + public void testDeploymentEvent() throws Exception { + Event event = unmarshalResource(DeploymentEvent.class, "deployment-event.json"); + assertTrue(compareJson(event, "deployment-event.json")); + } + @Test public void testIssueEvent() throws Exception { diff --git a/src/test/resources/org/gitlab4j/api/deployment-event.json b/src/test/resources/org/gitlab4j/api/deployment-event.json new file mode 100644 index 00000000..253d661d --- /dev/null +++ b/src/test/resources/org/gitlab4j/api/deployment-event.json @@ -0,0 +1,37 @@ +{ + "commit_title": "Add new file", + "commit_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/commit/279484c09fbe69ededfced8c1bb6e6d24616b468", + "deployment_id": 15, + "deployable_id": 796, + "deployable_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/jobs/796", + "environment": "staging", + "object_kind": "deployment", + "project": { + "ci_config_path": "", + "default_branch": "master", + "description": "", + "git_http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git", + "git_ssh_url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git", + "homepage": "http://10.126.0.2:3000/root/test-deployment-webhooks", + "http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git", + "id": 30, + "name": "test-deployment-webhooks", + "namespace": "Administrator", + "path_with_namespace": "root/test-deployment-webhooks", + "ssh_url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git", + "url": "ssh://vlad@10.126.0.2:2222/root/test-deployment-webhooks.git", + "visibility_level": 0, + "web_url": "http://10.126.0.2:3000/root/test-deployment-webhooks" + }, + "short_sha": "279484c0", + "status": "success", + "status_changed_at": "2021-04-28 21:50:00 +0200", + "user": { + "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "email": "admin@example.com", + "id": 1, + "name": "Administrator", + "username": "root" + }, + "user_url": "http://10.126.0.2:3000/root" +} diff --git a/src/test/resources/org/gitlab4j/api/environment.json b/src/test/resources/org/gitlab4j/api/environment.json index ff77773d..e3a02042 100644 --- a/src/test/resources/org/gitlab4j/api/environment.json +++ b/src/test/resources/org/gitlab4j/api/environment.json @@ -5,6 +5,7 @@ "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com", "state": "available", "tier": "testing", + "auto_stop_at": "2024-11-27T13:34:49.812Z", "last_deployment": { "id": 100, "iid": 34,