Skip to content

Commit 4c38074

Browse files
Add missing deployment and environment attributes (#1187)
1 parent 1113839 commit 4c38074

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

src/main/java/org/gitlab4j/api/models/Environment.java

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.gitlab4j.api.models;
22

33
import java.io.Serializable;
4+
import java.util.Date;
45

56
import org.gitlab4j.api.utils.JacksonJson;
67
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
@@ -41,6 +42,7 @@ public String toString() {
4142
private String tier;
4243
private EnvironmentState state;
4344
private Deployment lastDeployment;
45+
private Date autoStopAt;
4446

4547
public Long getId() {
4648
return id;
@@ -98,6 +100,14 @@ public void setLastDeployment(Deployment lastDeployment) {
98100
this.lastDeployment = lastDeployment;
99101
}
100102

103+
public Date getAutoStopAt() {
104+
return autoStopAt;
105+
}
106+
107+
public void setAutoStopAt(Date autoStopAt) {
108+
this.autoStopAt = autoStopAt;
109+
}
110+
101111
@Override
102112
public String toString() {
103113
return (JacksonJson.toJsonString(this));

src/main/java/org/gitlab4j/api/webhook/DeploymentEvent.java

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class DeploymentEvent extends AbstractEvent {
1212
private String status;
1313
private String statusChangedAt;
1414
private Long deployableId;
15+
private Long deploymentId;
1516
private String deployableUrl;
1617
private String environment;
1718
private EventProject project;
@@ -55,6 +56,14 @@ public void setDeployableId(Long deployableId) {
5556
this.deployableId = deployableId;
5657
}
5758

59+
public Long getDeploymentId() {
60+
return deploymentId;
61+
}
62+
63+
public void setDeploymentId(Long deploymentId) {
64+
this.deploymentId = deploymentId;
65+
}
66+
5867
public String getDeployableUrl() {
5968
return deployableUrl;
6069
}

src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.gitlab4j.api.utils.JacksonJson;
2727
import org.gitlab4j.api.webhook.BuildEvent;
2828
import org.gitlab4j.api.webhook.ChangeContainer;
29+
import org.gitlab4j.api.webhook.DeploymentEvent;
2930
import org.gitlab4j.api.webhook.Event;
3031
import org.gitlab4j.api.webhook.IssueEvent;
3132
import org.gitlab4j.api.webhook.JobEvent;
@@ -65,6 +66,12 @@ public static void teardown() {
6566
GitLabApi.getLogger().setLevel(savedLevel);
6667
}
6768

69+
@Test
70+
public void testDeploymentEvent() throws Exception {
71+
Event event = unmarshalResource(DeploymentEvent.class, "deployment-event.json");
72+
assertTrue(compareJson(event, "deployment-event.json"));
73+
}
74+
6875
@Test
6976
public void testIssueEvent() throws Exception {
7077

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"commit_title": "Add new file",
3+
"commit_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/commit/279484c09fbe69ededfced8c1bb6e6d24616b468",
4+
"deployment_id": 15,
5+
"deployable_id": 796,
6+
"deployable_url": "http://10.126.0.2:3000/root/test-deployment-webhooks/-/jobs/796",
7+
"environment": "staging",
8+
"object_kind": "deployment",
9+
"project": {
10+
"ci_config_path": "",
11+
"default_branch": "master",
12+
"description": "",
13+
"git_http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git",
14+
"git_ssh_url": "ssh://[email protected]:2222/root/test-deployment-webhooks.git",
15+
"homepage": "http://10.126.0.2:3000/root/test-deployment-webhooks",
16+
"http_url": "http://10.126.0.2:3000/root/test-deployment-webhooks.git",
17+
"id": 30,
18+
"name": "test-deployment-webhooks",
19+
"namespace": "Administrator",
20+
"path_with_namespace": "root/test-deployment-webhooks",
21+
"ssh_url": "ssh://[email protected]:2222/root/test-deployment-webhooks.git",
22+
"url": "ssh://[email protected]:2222/root/test-deployment-webhooks.git",
23+
"visibility_level": 0,
24+
"web_url": "http://10.126.0.2:3000/root/test-deployment-webhooks"
25+
},
26+
"short_sha": "279484c0",
27+
"status": "success",
28+
"status_changed_at": "2021-04-28 21:50:00 +0200",
29+
"user": {
30+
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
31+
"email": "[email protected]",
32+
"id": 1,
33+
"name": "Administrator",
34+
"username": "root"
35+
},
36+
"user_url": "http://10.126.0.2:3000/root"
37+
}

src/test/resources/org/gitlab4j/api/environment.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
66
"state": "available",
77
"tier": "testing",
8+
"auto_stop_at": "2024-11-27T13:34:49.812Z",
89
"last_deployment": {
910
"id": 100,
1011
"iid": 34,

0 commit comments

Comments
 (0)