Unverified Commit 906e79ad authored by Jérémie Bresson's avatar Jérémie Bresson Committed by GitHub
Browse files

Add 'pipelineId' to CommitStatus (#1064)

Fixes https://github.com/gitlab4j/gitlab4j-api/issues/1058
parent 9cc6d2d1
...@@ -3,6 +3,7 @@ package org.gitlab4j.api; ...@@ -3,6 +3,7 @@ package org.gitlab4j.api;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -590,7 +591,9 @@ public class CommitsApi extends AbstractApi { ...@@ -590,7 +591,9 @@ public class CommitsApi extends AbstractApi {
* @param status the CommitSatus instance hoilding the optional parms: ref, name, target_url, description, and coverage * @param status the CommitSatus instance hoilding the optional parms: ref, name, target_url, description, and coverage
* @return a CommitStatus instance with the updated info * @return a CommitStatus instance with the updated info
* @throws GitLabApiException GitLabApiException if any exception occurs during execution * @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @deprecated use {@link #addCommitStatus(Object, String, org.gitlab4j.api.Constants.CommitBuildState, CommitStatus)} and set the pipelineId value in the {@link CommitStatus} parameter
*/ */
@Deprecated
public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, Long pipelineId, CommitStatus status) throws GitLabApiException { public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, Long pipelineId, CommitStatus status) throws GitLabApiException {
if (projectIdOrPath == null) { if (projectIdOrPath == null) {
...@@ -607,7 +610,11 @@ public class CommitsApi extends AbstractApi { ...@@ -607,7 +610,11 @@ public class CommitsApi extends AbstractApi {
.withParam("name", status.getName()) .withParam("name", status.getName())
.withParam("target_url", status.getTargetUrl()) .withParam("target_url", status.getTargetUrl())
.withParam("description", status.getDescription()) .withParam("description", status.getDescription())
.withParam("coverage", status.getCoverage()); .withParam("coverage", status.getCoverage())
.withParam("pipeline_id", status.getPipelineId());
if (pipelineId != null && status.getPipelineId() != null && !Objects.equals(status.getPipelineId(), pipelineId)) {
throw new IllegalArgumentException("The parameter 'pipelineId' and the pipelineId value the 'status' parameter are different. Set the two values to be the same or one of the two values to null.");
}
} }
if (pipelineId != null) { if (pipelineId != null) {
......
...@@ -15,6 +15,7 @@ public class CommitStatus { ...@@ -15,6 +15,7 @@ public class CommitStatus {
private Date finishedAt; private Date finishedAt;
private Long id; private Long id;
private String name; private String name;
private Long pipelineId;
private String ref; private String ref;
private String sha; private String sha;
private Date startedAt; private Date startedAt;
...@@ -85,6 +86,14 @@ public class CommitStatus { ...@@ -85,6 +86,14 @@ public class CommitStatus {
this.name = name; this.name = name;
} }
public Long getPipelineId() {
return pipelineId;
}
public void setPipelineId(Long pipelineId) {
this.pipelineId = pipelineId;
}
public String getRef() { public String getRef() {
return ref; return ref;
} }
...@@ -140,6 +149,11 @@ public class CommitStatus { ...@@ -140,6 +149,11 @@ public class CommitStatus {
return this; return this;
} }
public CommitStatus withPipelineId(Long pipelineId) {
this.pipelineId = pipelineId;
return this;
}
public CommitStatus withRef(String ref) { public CommitStatus withRef(String ref) {
this.ref = ref; this.ref = ref;
return this; return this;
......
{ {
"status" : "pending", "id": 78919,
"created_at" : "2016-01-19T08:40:25.934Z", "sha": "6b9fec60e107f1f323dfa6674b317facd996cb0a",
"started_at" : "2016-01-19T08:40:25.934Z", "ref": "cccct",
"name" : "bundler:audit", "status": "failed",
"allow_failure" : true, "name": "extci",
"author" : { "target_url": "https://example.com/ext/6b9fec60e107f1f323dfa6674b317facd996cb0a/",
"username" : "thedude", "description": "External check",
"state" : "active", "created_at": "2023-04-03T11:05:27.792Z",
"web_url" : "https://gitlab.example.com/thedude", "started_at": "2023-04-03T11:05:29.205Z",
"avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/The-Big-Lebowski-400-400.png", "finished_at": "2023-04-03T11:16:05.803Z",
"id" : 28, "allow_failure": false,
"name" : "Jeff Lebowski" "coverage": 10.8,
}, "pipeline_id": 15641,
"description" : "this is a description", "author": {
"sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8", "id": 7,
"target_url" : "https://gitlab.example.com/thedude/gitlab-ce/builds/91", "name": "Pamella Huel",
"finished_at" : "2016-01-19T08:40:25.934Z", "username": "arnita",
"id" : 2148826854, "state": "active",
"ref" : "master" "avatar_url": "http://www.gravatar.com/avatar/a2f5c6fcef64c9c69cb8779cb292be1b?s=80&d=identicon",
} "web_url": "http://gitlab.example.com/arnita"
\ No newline at end of file }
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment