Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing deployment and environment attributes #1187

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add missing deployment and environment attributes
katrinSaleschus authored and jmini committed Nov 28, 2024
commit db5649a48ac19ffd497d0041d948e8fcba1b5d6c
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;
@@ -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));
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
@@ -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;
}
7 changes: 7 additions & 0 deletions src/test/java/org/gitlab4j/api/TestGitLabApiEvents.java
Original file line number Diff line number Diff line change
@@ -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 {

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://[email protected]: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://[email protected]:2222/root/test-deployment-webhooks.git",
"url": "ssh://[email protected]: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": "[email protected]",
"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
@@ -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,