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;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
......@@ -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
* @return a CommitStatus instance with the updated info
* @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 {
if (projectIdOrPath == null) {
......@@ -607,7 +610,11 @@ public class CommitsApi extends AbstractApi {
.withParam("name", status.getName())
.withParam("target_url", status.getTargetUrl())
.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) {
......
......@@ -15,6 +15,7 @@ public class CommitStatus {
private Date finishedAt;
private Long id;
private String name;
private Long pipelineId;
private String ref;
private String sha;
private Date startedAt;
......@@ -85,6 +86,14 @@ public class CommitStatus {
this.name = name;
}
public Long getPipelineId() {
return pipelineId;
}
public void setPipelineId(Long pipelineId) {
this.pipelineId = pipelineId;
}
public String getRef() {
return ref;
}
......@@ -140,6 +149,11 @@ public class CommitStatus {
return this;
}
public CommitStatus withPipelineId(Long pipelineId) {
this.pipelineId = pipelineId;
return this;
}
public CommitStatus withRef(String ref) {
this.ref = ref;
return this;
......
{
"status" : "pending",
"created_at" : "2016-01-19T08:40:25.934Z",
"started_at" : "2016-01-19T08:40:25.934Z",
"name" : "bundler:audit",
"allow_failure" : true,
"author" : {
"username" : "thedude",
"state" : "active",
"web_url" : "https://gitlab.example.com/thedude",
"avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/The-Big-Lebowski-400-400.png",
"id" : 28,
"name" : "Jeff Lebowski"
},
"description" : "this is a description",
"sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
"target_url" : "https://gitlab.example.com/thedude/gitlab-ce/builds/91",
"finished_at" : "2016-01-19T08:40:25.934Z",
"id" : 2148826854,
"ref" : "master"
}
\ No newline at end of file
"id": 78919,
"sha": "6b9fec60e107f1f323dfa6674b317facd996cb0a",
"ref": "cccct",
"status": "failed",
"name": "extci",
"target_url": "https://example.com/ext/6b9fec60e107f1f323dfa6674b317facd996cb0a/",
"description": "External check",
"created_at": "2023-04-03T11:05:27.792Z",
"started_at": "2023-04-03T11:05:29.205Z",
"finished_at": "2023-04-03T11:16:05.803Z",
"allow_failure": false,
"coverage": 10.8,
"pipeline_id": 15641,
"author": {
"id": 7,
"name": "Pamella Huel",
"username": "arnita",
"state": "active",
"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
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