From cfaa09cadcbeb597db4973ddbc969af88d586078 Mon Sep 17 00:00:00 2001 From: Greg Messner Date: Sat, 9 Nov 2019 10:22:16 -0800 Subject: [PATCH] Add support for Environments API - #463 (#472) --- src/main/java/org/gitlab4j/api/Constants.java | 23 +++ .../org/gitlab4j/api/EnvironmentsApi.java | 162 ++++++++++++++++ src/main/java/org/gitlab4j/api/GitLabApi.java | 20 ++ .../org/gitlab4j/api/models/Artifact.java | 2 +- .../org/gitlab4j/api/models/Deployable.java | 178 ++++++++++++++++++ .../org/gitlab4j/api/models/Deployment.java | 105 +++++++++++ .../org/gitlab4j/api/models/Environment.java | 91 +++++++++ .../org/gitlab4j/api/TestEnvironmentsApi.java | 130 +++++++++++++ .../org/gitlab4j/api/TestGitLabApiBeans.java | 14 ++ .../org/gitlab4j/api/deployment.json | 54 ++++++ .../org/gitlab4j/api/environment.json | 81 ++++++++ src/test/resources/org/gitlab4j/api/job.json | 1 - 12 files changed, 859 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/gitlab4j/api/EnvironmentsApi.java create mode 100644 src/main/java/org/gitlab4j/api/models/Deployable.java create mode 100644 src/main/java/org/gitlab4j/api/models/Deployment.java create mode 100644 src/main/java/org/gitlab4j/api/models/Environment.java create mode 100644 src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java create mode 100644 src/test/resources/org/gitlab4j/api/deployment.json create mode 100644 src/test/resources/org/gitlab4j/api/environment.json diff --git a/src/main/java/org/gitlab4j/api/Constants.java b/src/main/java/org/gitlab4j/api/Constants.java index 967ef55a..0d57be21 100644 --- a/src/main/java/org/gitlab4j/api/Constants.java +++ b/src/main/java/org/gitlab4j/api/Constants.java @@ -780,4 +780,27 @@ public interface Constants { return (enumHelper.toString(this)); } } + + /** Enum to use for specifying the status of a deployment. */ + public enum DeploymentStatus { + + CREATED, RUNNING, SUCCESS, FAILED, CANCELED; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(DeploymentStatus.class); + + @JsonCreator + public static DeploymentStatus forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } } diff --git a/src/main/java/org/gitlab4j/api/EnvironmentsApi.java b/src/main/java/org/gitlab4j/api/EnvironmentsApi.java new file mode 100644 index 00000000..8aa87b64 --- /dev/null +++ b/src/main/java/org/gitlab4j/api/EnvironmentsApi.java @@ -0,0 +1,162 @@ +package org.gitlab4j.api; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Stream; + +import javax.ws.rs.core.Response; + +import org.gitlab4j.api.models.Environment; + +/** + * This class provides an entry point to all the GitLab API Environments API calls. + * @see Environments API + */ +public class EnvironmentsApi extends AbstractApi { + + public EnvironmentsApi(GitLabApi gitLabApi) { + super(gitLabApi); + } + + /** + * Get all environments for a given project. + * + *
GitLab Endpoint: GET /projects/:id/environments
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @return a List of Environment instances + * @throws GitLabApiException if any exception occurs + */ + public List getEnvironments(Object projectIdOrPath) throws GitLabApiException { + return (getEnvironments(projectIdOrPath, getDefaultPerPage()).all()); + } + + /** + * Get a Stream of all environments for a given project. + * + *
GitLab Endpoint: GET /projects/:id/environments
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @return a Stream of Environment instances + * @throws GitLabApiException if any exception occurs + */ + public Stream getEnvironmentsStream(Object projectIdOrPath) throws GitLabApiException { + return (getEnvironments(projectIdOrPath, getDefaultPerPage()).stream()); + } + + /** + * Get a Pager of all environments for a given project. + * + *
GitLab Endpoint: GET /projects/:id/environments
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param itemsPerPage the number of Environment instances that will be fetched per page + * @return a Pager of Environment instances + * @throws GitLabApiException if any exception occurs + */ + public Pager getEnvironments(Object projectIdOrPath, int itemsPerPage) throws GitLabApiException { + return (new Pager(this, Environment.class, itemsPerPage, null, + "projects", getProjectIdOrPath(projectIdOrPath), "environments")); + } + + /** + * Get a specific environment. + * + *
GitLab Endpoint: GET /projects/:id/environments/:environment_id
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param environmentId the ID of the environment to get + * @return an Environment instance + * @throws GitLabApiException if any exception occurs + */ + public Environment getEnvironment(Object projectIdOrPath, Integer environmentId) throws GitLabApiException { + Response response = get(Response.Status.OK, null, + "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); + return (response.readEntity(Environment.class)); + } + + /** + * Get a specific environment. as an Optional instance. + * + *
GitLab Endpoint: GET /projects/:id/environments/:environment_id
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param environmentId the ID of the environment to get + * @return the Environment as an Optional instance + */ + public Optional getOptionalEnvironment(Object projectIdOrPath, Integer environmentId) { + try { + return (Optional.ofNullable(getEnvironment(projectIdOrPath, environmentId))); + } catch (GitLabApiException glae) { + return (GitLabApi.createOptionalFromException(glae)); + } + } + + /** + * Create a new environment with the given name and external_url. + * + *
GitLab Endpoint:POST /projects/:id/environments
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param name the name of the environment + * @param externalUrl the place to link to for this environment + * @return the created Environment instance + * @throws GitLabApiException if any exception occurs + */ + public Environment createEnvironment(Object projectIdOrPath, String name, String externalUrl) throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm().withParam("name", name, true).withParam("external_url", externalUrl); + Response response = post(Response.Status.CREATED, formData, + "projects", getProjectIdOrPath(projectIdOrPath), "environments"); + return (response.readEntity(Environment.class)); + } + + /** + * Update an existing environment. + * + *
GitLab Endpoint:POST /projects/:id/environments
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param environmentId the ID of the environment to update + * @param name the name of the environment + * @param externalUrl the place to link to for this environment + * @return the created Environment instance + * @throws GitLabApiException if any exception occurs + */ + public Environment updateEnvironment(Object projectIdOrPath, Integer environmentId, String name, String externalUrl) throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm().withParam("name", name).withParam("external_url", externalUrl); + Response response = putWithFormData(Response.Status.OK, formData, formData, + "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); + return (response.readEntity(Environment.class)); + } + + /** + * Delete an environment. + * + *
GitLab Endpoint: DELETE /projects/:id/environments/:environment_id
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param environmentId the ID of the environment to delete + * @throws GitLabApiException if any exception occurs + */ + public void deleteEnvironment(Object projectIdOrPath, Integer environmentId) throws GitLabApiException { + delete(Response.Status.OK, null, + "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId); + } + + /** + * Stop an environment. + * + *
GitLab Endpoint:POST /projects/:id/environments/:environment_id/stop
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param environmentId the ID of the environment to stop + * @return the Environment instance of the stopped environment + * @throws GitLabApiException if any exception occurs + */ + public Environment createEnvironment(Object projectIdOrPath, Integer environmentId) throws GitLabApiException { + GitLabApiForm formData = new GitLabApiForm(); + Response response = post(Response.Status.CREATED, formData, + "projects", getProjectIdOrPath(projectIdOrPath), "environments", environmentId, "stop"); + return (response.readEntity(Environment.class)); + } +} \ No newline at end of file diff --git a/src/main/java/org/gitlab4j/api/GitLabApi.java b/src/main/java/org/gitlab4j/api/GitLabApi.java index a7556451..49daf817 100644 --- a/src/main/java/org/gitlab4j/api/GitLabApi.java +++ b/src/main/java/org/gitlab4j/api/GitLabApi.java @@ -59,6 +59,7 @@ public class GitLabApi { private ContainerRegistryApi containerRegistryApi; private DiscussionsApi discussionsApi; private DeployKeysApi deployKeysApi; + private EnvironmentsApi environmentsApi; private EpicsApi epicsApi; private EventsApi eventsApi; private GroupApi groupApi; @@ -1054,6 +1055,25 @@ public class GitLabApi { return (discussionsApi); } + /** + * Gets the EnvironmentsApi instance owned by this GitLabApi instance. The EnvironmentsApi is used + * to perform all environment related API calls. + * + * @return the EnvironmentsApi instance owned by this GitLabApi instance + */ + public EnvironmentsApi getEnvironmentsApi() { + + if (environmentsApi == null) { + synchronized (this) { + if (environmentsApi == null) { + environmentsApi = new EnvironmentsApi(this); + } + } + } + + return (environmentsApi); + } + /** * Gets the EpicsApi instance owned by this GitLabApi instance. The EpicsApi is used * to perform all Epics and Epic Issues related API calls. diff --git a/src/main/java/org/gitlab4j/api/models/Artifact.java b/src/main/java/org/gitlab4j/api/models/Artifact.java index 2395f4ba..fb0e1ed3 100644 --- a/src/main/java/org/gitlab4j/api/models/Artifact.java +++ b/src/main/java/org/gitlab4j/api/models/Artifact.java @@ -11,7 +11,7 @@ public class Artifact { public enum FileType { ARCHIVE, METADATA, TRACE, JUNIT; - private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(FileType.class, true); + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(FileType.class); @JsonCreator public static FileType forValue(String value) { diff --git a/src/main/java/org/gitlab4j/api/models/Deployable.java b/src/main/java/org/gitlab4j/api/models/Deployable.java new file mode 100644 index 00000000..dfae5809 --- /dev/null +++ b/src/main/java/org/gitlab4j/api/models/Deployable.java @@ -0,0 +1,178 @@ +package org.gitlab4j.api.models; + +import java.util.Date; +import java.util.List; + +import org.gitlab4j.api.Constants.DeploymentStatus; +import org.gitlab4j.api.utils.JacksonJson; + +public class Deployable { + + private Integer id; + private DeploymentStatus status; + private String stage; + private String name; + private String ref; + private Boolean tag; + private Float coverage; + private Date createdAt; + private Date startedAt; + private Date finishedAt; + private Double duration; + private User user; + private Commit commit; + private Pipeline pipeline; + private String webUrl; + private List artifacts; + private Runner runner; + private Date artifactsExpireAt; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public DeploymentStatus getStatus() { + return status; + } + + public void setStatus(DeploymentStatus status) { + this.status = status; + } + + public String getStage() { + return stage; + } + + public void setStage(String stage) { + this.stage = stage; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public Boolean getTag() { + return tag; + } + + public void setTag(Boolean tag) { + this.tag = tag; + } + + public Float getCoverage() { + return coverage; + } + + public void setCoverage(Float coverage) { + this.coverage = coverage; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getStartedAt() { + return startedAt; + } + + public void setStartedAt(Date startedAt) { + this.startedAt = startedAt; + } + + public Date getFinishedAt() { + return finishedAt; + } + + public void setFinishedAt(Date finishedAt) { + this.finishedAt = finishedAt; + } + + public Double getDuration() { + return duration; + } + + public void setDuration(Double duration) { + this.duration = duration; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Commit getCommit() { + return commit; + } + + public void setCommit(Commit commit) { + this.commit = commit; + } + + public Pipeline getPipeline() { + return pipeline; + } + + public void setPipeline(Pipeline pipeline) { + this.pipeline = pipeline; + } + + public String getWebUrl() { + return webUrl; + } + + public void setWebUrl(String webUrl) { + this.webUrl = webUrl; + } + + public List getArtifacts() { + return artifacts; + } + + public void setArtifacts(List artifacts) { + this.artifacts = artifacts; + } + + public Runner getRunner() { + return runner; + } + + public void setRunner(Runner runner) { + this.runner = runner; + } + + public Date getArtifactsExpireAt() { + return artifactsExpireAt; + } + + public void setArtifactsExpireAt(Date artifactsExpireAt) { + this.artifactsExpireAt = artifactsExpireAt; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } +} diff --git a/src/main/java/org/gitlab4j/api/models/Deployment.java b/src/main/java/org/gitlab4j/api/models/Deployment.java new file mode 100644 index 00000000..8480e94c --- /dev/null +++ b/src/main/java/org/gitlab4j/api/models/Deployment.java @@ -0,0 +1,105 @@ +package org.gitlab4j.api.models; + +import java.util.Date; + +import org.gitlab4j.api.Constants.DeploymentStatus; +import org.gitlab4j.api.utils.JacksonJson; + +public class Deployment { + + private Integer id; + private Integer iid; + private String ref; + private String sha; + private Date createdAt; + private Date updatedAt; + private DeploymentStatus status; + private User user; + private Environment environment; + private Deployable deployable; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getIid() { + return iid; + } + + public void setIid(Integer iid) { + this.iid = iid; + } + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getSha() { + return sha; + } + + public void setSha(String sha) { + this.sha = sha; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public DeploymentStatus getStatus() { + return status; + } + + public void setStatus(DeploymentStatus status) { + this.status = status; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Environment getEnvironment() { + return environment; + } + + public void setEnvironment(Environment environment) { + this.environment = environment; + } + + public Deployable getDeployable() { + return deployable; + } + + public void setDeployable(Deployable deployable) { + this.deployable = deployable; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } +} diff --git a/src/main/java/org/gitlab4j/api/models/Environment.java b/src/main/java/org/gitlab4j/api/models/Environment.java new file mode 100644 index 00000000..a6e4ec38 --- /dev/null +++ b/src/main/java/org/gitlab4j/api/models/Environment.java @@ -0,0 +1,91 @@ +package org.gitlab4j.api.models; + +import org.gitlab4j.api.utils.JacksonJson; +import org.gitlab4j.api.utils.JacksonJsonEnumHelper; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public class Environment { + + public enum EnvironmentState { + AVAILABLE, STOPPED; + + private static JacksonJsonEnumHelper enumHelper = new JacksonJsonEnumHelper<>(EnvironmentState.class); + + @JsonCreator + public static EnvironmentState forValue(String value) { + return enumHelper.forValue(value); + } + + @JsonValue + public String toValue() { + return (enumHelper.toString(this)); + } + + @Override + public String toString() { + return (enumHelper.toString(this)); + } + } + + private Integer id; + private String name; + private String slug; + private String externalUrl; + private EnvironmentState state; + private Deployment lastDeployment; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSlug() { + return slug; + } + + public void setSlug(String slug) { + this.slug = slug; + } + + public String getExternalUrl() { + return externalUrl; + } + + public void setExternalUrl(String externalUrl) { + this.externalUrl = externalUrl; + } + + public EnvironmentState getState() { + return state; + } + + public void setState(EnvironmentState state) { + this.state = state; + } + + public Deployment getLastDeployment() { + return lastDeployment; + } + + public void setLastDeployment(Deployment lastDeployment) { + this.lastDeployment = lastDeployment; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } +} diff --git a/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java b/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java new file mode 100644 index 00000000..d256f4ea --- /dev/null +++ b/src/test/java/org/gitlab4j/api/TestEnvironmentsApi.java @@ -0,0 +1,130 @@ +package org.gitlab4j.api; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeNotNull; + +import java.util.List; +import java.util.Optional; +import java.util.Random; +import java.util.stream.Stream; + +import org.gitlab4j.api.models.Environment; +import org.gitlab4j.api.models.Project; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +/** + * In order for these tests to run you must set the following properties in + * ~/test-gitlab4j.properties + *

+ * TEST_HOST_URL + * TEST_PRIVATE_TOKEN + *

+ * If any of the above are NULL, all tests in this class will be skipped. + */ +@Category(IntegrationTest.class) +public class TestEnvironmentsApi extends AbstractIntegrationTest { + + private static GitLabApi gitLabApi; + private static Project testProject; + + private static final String ENVIRONMENT_NAME = "gitlab4j-testing"; + private static final String EXTERNAL_URL = "https:/testing.example.com/"; + private static Random randomNumberGenerator = new Random(); + + public TestEnvironmentsApi() { + super(); + } + + @BeforeClass + public static void setup() { + + // Must setup the connection to the GitLab test server and get the test Project + // instance + gitLabApi = baseTestSetup(); + testProject = getTestProject(); + + deleteAllTestAssets(); + } + + @AfterClass + public static void teardown() throws GitLabApiException { + deleteAllTestAssets(); + } + + private static void deleteAllTestAssets() { + + if (gitLabApi != null) { + try { + List envs = gitLabApi.getEnvironmentsApi().getEnvironments(testProject); + if (envs != null) { + + for (Environment env : envs) { + if (env.getName().startsWith(ENVIRONMENT_NAME)) { + gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId()); + } + } + } + } catch (GitLabApiException ignore) { + } + } + } + + @Before + public void beforeMethod() { + assumeNotNull(gitLabApi); + } + + private static String getUniqueName() { + return (ENVIRONMENT_NAME + " - " + (randomNumberGenerator.nextInt() + 1)); + } + + @Test + public void testGetEnvironments() throws GitLabApiException { + + final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment( + testProject, getUniqueName(), EXTERNAL_URL); + + try { + List envs = gitLabApi.getEnvironmentsApi().getEnvironments(testProject); + assertTrue(envs.size() > 0); + Environment foundEnv = envs.stream().filter( + e -> e.getName().equals(env.getName())).findFirst().orElse(null); + assertNotNull(foundEnv); + assertEquals(env.getName(), foundEnv.getName()); + } catch (Exception e) { + gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId()); + } + } + + @Test + public void testDeleteEnvironment() throws GitLabApiException { + + final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment( + testProject, getUniqueName(), EXTERNAL_URL); + gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId()); + + Stream envs = gitLabApi.getEnvironmentsApi().getEnvironmentsStream(testProject); + Environment foundEnv = envs.filter(e -> e.getName().equals(env.getName())).findFirst().orElse(null); + assertNull(foundEnv); + } + + @Test + public void testOptionalEnvironment() throws GitLabApiException { + + final Environment env = gitLabApi.getEnvironmentsApi().createEnvironment( + testProject, getUniqueName(), EXTERNAL_URL); + Optional optionalEnv = + gitLabApi.getEnvironmentsApi().getOptionalEnvironment(testProject, env.getId()); + assertTrue(optionalEnv.isPresent()); + assertEquals(env.getName(), optionalEnv.get().getName()); + + gitLabApi.getEnvironmentsApi().deleteEnvironment(testProject, env.getId()); + } +} diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java index 178fefe2..6c232d5c 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java @@ -48,9 +48,11 @@ import org.gitlab4j.api.models.CommitStatus; import org.gitlab4j.api.models.CompareResults; import org.gitlab4j.api.models.Contributor; import org.gitlab4j.api.models.DeployKey; +import org.gitlab4j.api.models.Deployment; import org.gitlab4j.api.models.Diff; import org.gitlab4j.api.models.Discussion; import org.gitlab4j.api.models.Email; +import org.gitlab4j.api.models.Environment; import org.gitlab4j.api.models.Epic; import org.gitlab4j.api.models.EpicIssue; import org.gitlab4j.api.models.Event; @@ -188,12 +190,24 @@ public class TestGitLabApiBeans { assertTrue(compareJson(comment, "comment.json")); } + @Test + public void testDeployment() throws Exception { + Deployment deployment = unmarshalResource(Deployment.class, "deployment.json"); + assertTrue(compareJson(deployment, "deployment.json")); + } + @Test public void testEmails() throws Exception { List emails = unmarshalResourceList(Email.class, "emails.json"); assertTrue(compareJson(emails, "emails.json")); } + @Test + public void testEnvironment() throws Exception { + Environment environment = unmarshalResource(Environment.class, "environment.json"); + assertTrue(compareJson(environment, "environment.json")); + } + @Test public void testEpic() throws Exception { Epic epic = unmarshalResource(Epic.class, "epic.json"); diff --git a/src/test/resources/org/gitlab4j/api/deployment.json b/src/test/resources/org/gitlab4j/api/deployment.json new file mode 100644 index 00000000..530fdda3 --- /dev/null +++ b/src/test/resources/org/gitlab4j/api/deployment.json @@ -0,0 +1,54 @@ +{ + "id": 42, + "iid": 2, + "ref": "master", + "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", + "created_at": "2016-08-11T11:32:35.444Z", + "updated_at": "2016-08-11T11:34:01.123Z", + "user": { + "name": "Administrator", + "username": "root", + "id": 1, + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://localhost:3000/root" + }, + "environment": { + "id": 9, + "name": "production", + "external_url": "https://about.gitlab.com" + }, + "deployable": { + "id": 664, + "status": "success", + "stage": "deploy", + "name": "deploy", + "ref": "master", + "tag": false, + "created_at": "2016-08-11T11:32:24.456Z", + "finished_at": "2016-08-11T11:32:35.145Z", + "user": { + "id": 1, + "name": "Administrator", + "username": "root", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://gitlab.dev/root", + "created_at": "2015-12-21T13:14:24.077Z", + "skype": "", + "linkedin": "", + "twitter": "", + "website_url": "", + "organization": "" + }, + "commit": { + "id": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", + "short_id": "a91957a8", + "title": "Merge branch 'rename-readme' into 'master'\r", + "author_name": "Administrator", + "author_email": "admin@example.com", + "created_at": "2016-08-11T13:28:26Z", + "message": "Merge branch 'rename-readme' into 'master'\r\n\r\nRename README\r\n\r\n\r\n\r\nSee merge request !2" + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/gitlab4j/api/environment.json b/src/test/resources/org/gitlab4j/api/environment.json new file mode 100644 index 00000000..03a64d24 --- /dev/null +++ b/src/test/resources/org/gitlab4j/api/environment.json @@ -0,0 +1,81 @@ +{ + "id": 1, + "name": "review/fix-foo", + "slug": "review-fix-foo-dfjre3", + "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com", + "state": "available", + "last_deployment": { + "id": 100, + "iid": 34, + "ref": "fdroid", + "sha": "416d8ea11849050d3d1f5104cf8cf51053e790ab", + "created_at": "2019-03-25T18:55:13.252Z", + "status": "success", + "user": { + "id": 1, + "name": "Administrator", + "state": "active", + "username": "root", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://localhost:3000/root" + }, + "deployable": { + "id": 710, + "status": "success", + "stage": "deploy", + "name": "staging", + "ref": "fdroid", + "tag": false, + "coverage": 87.65, + "created_at": "2019-03-25T18:55:13.215Z", + "started_at": "2019-03-25T12:54:50.082Z", + "finished_at": "2019-03-25T18:55:13.216Z", + "duration": 21623.13423, + "user": { + "id": 1, + "name": "Administrator", + "username": "root", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://gitlab.dev/root", + "created_at": "2015-12-21T13:14:24.077Z", + "public_email": "", + "skype": "", + "linkedin": "", + "twitter": "", + "website_url": "" + }, + "commit": { + "id": "416d8ea11849050d3d1f5104cf8cf51053e790ab", + "short_id": "416d8ea1", + "created_at": "2016-01-02T15:39:18Z", + "parent_ids": [ + "e9a4449c95c64358840902508fc827f1a2eab7df" + ], + "title": "Removed fabric to fix #40", + "message": "Removed fabric to fix #40\n", + "author_name": "Administrator", + "author_email": "admin@example.com", + "authored_date": "2016-01-02T15:39:18Z", + "committer_name": "Administrator", + "committer_email": "admin@example.com", + "committed_date": "2016-01-02T15:39:18Z" + }, + "pipeline": { + "id": 34, + "sha": "416d8ea11849050d3d1f5104cf8cf51053e790ab", + "ref": "fdroid", + "status": "success", + "web_url": "http://localhost:3000/Commit451/lab-coat/pipelines/34" + }, + "web_url": "http://localhost:3000/Commit451/lab-coat/-/jobs/710", + "artifacts": [ + { + "file_type": "trace", + "size": 1305, + "filename": "job.log" + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/org/gitlab4j/api/job.json b/src/test/resources/org/gitlab4j/api/job.json index 99ec28ef..6fb8651a 100644 --- a/src/test/resources/org/gitlab4j/api/job.json +++ b/src/test/resources/org/gitlab4j/api/job.json @@ -30,7 +30,6 @@ "status": "pending" }, "ref": "master", - "artifacts": [], "stage": "test", "started_at": "2015-12-24T17:54:27.722Z", "status": "failed", -- GitLab