Skip to content

Commit

Permalink
Add missing deployment and environment attributes (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinSaleschus authored Nov 28, 2024
1 parent 1113839 commit 4c38074
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/gitlab4j/api/models/Environment.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,6 +42,7 @@ public String toString() {
private String tier;
private EnvironmentState state;
private Deployment lastDeployment;
private Date autoStopAt;

public Long getId() {
return id;
Expand Down Expand Up @@ -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));
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/gitlab4j/api/webhook/DeploymentEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {

Expand Down
37 changes: 37 additions & 0 deletions src/test/resources/org/gitlab4j/api/deployment-event.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions src/test/resources/org/gitlab4j/api/environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4c38074

Please sign in to comment.