Skip to content

Commit 906e79a

Browse files
authored
Add 'pipelineId' to CommitStatus (#1064)
Fixes #1058
1 parent 9cc6d2d commit 906e79a

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

src/main/java/org/gitlab4j/api/CommitsApi.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.Arrays;
44
import java.util.Date;
55
import java.util.List;
6+
import java.util.Objects;
67
import java.util.Optional;
78
import java.util.stream.Stream;
89

@@ -590,7 +591,9 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu
590591
* @param status the CommitSatus instance hoilding the optional parms: ref, name, target_url, description, and coverage
591592
* @return a CommitStatus instance with the updated info
592593
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
594+
* @deprecated use {@link #addCommitStatus(Object, String, org.gitlab4j.api.Constants.CommitBuildState, CommitStatus)} and set the pipelineId value in the {@link CommitStatus} parameter
593595
*/
596+
@Deprecated
594597
public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBuildState state, Long pipelineId, CommitStatus status) throws GitLabApiException {
595598

596599
if (projectIdOrPath == null) {
@@ -607,7 +610,11 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu
607610
.withParam("name", status.getName())
608611
.withParam("target_url", status.getTargetUrl())
609612
.withParam("description", status.getDescription())
610-
.withParam("coverage", status.getCoverage());
613+
.withParam("coverage", status.getCoverage())
614+
.withParam("pipeline_id", status.getPipelineId());
615+
if (pipelineId != null && status.getPipelineId() != null && !Objects.equals(status.getPipelineId(), pipelineId)) {
616+
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.");
617+
}
611618
}
612619

613620
if (pipelineId != null) {

src/main/java/org/gitlab4j/api/models/CommitStatus.java

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class CommitStatus {
1515
private Date finishedAt;
1616
private Long id;
1717
private String name;
18+
private Long pipelineId;
1819
private String ref;
1920
private String sha;
2021
private Date startedAt;
@@ -85,6 +86,14 @@ public void setName(String name) {
8586
this.name = name;
8687
}
8788

89+
public Long getPipelineId() {
90+
return pipelineId;
91+
}
92+
93+
public void setPipelineId(Long pipelineId) {
94+
this.pipelineId = pipelineId;
95+
}
96+
8897
public String getRef() {
8998
return ref;
9099
}
@@ -140,6 +149,11 @@ public CommitStatus withName(String name) {
140149
return this;
141150
}
142151

152+
public CommitStatus withPipelineId(Long pipelineId) {
153+
this.pipelineId = pipelineId;
154+
return this;
155+
}
156+
143157
public CommitStatus withRef(String ref) {
144158
this.ref = ref;
145159
return this;
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
2-
"status" : "pending",
3-
"created_at" : "2016-01-19T08:40:25.934Z",
4-
"started_at" : "2016-01-19T08:40:25.934Z",
5-
"name" : "bundler:audit",
6-
"allow_failure" : true,
7-
"author" : {
8-
"username" : "thedude",
9-
"state" : "active",
10-
"web_url" : "https://gitlab.example.com/thedude",
11-
"avatar_url" : "https://gitlab.example.com/uploads/user/avatar/28/The-Big-Lebowski-400-400.png",
12-
"id" : 28,
13-
"name" : "Jeff Lebowski"
14-
},
15-
"description" : "this is a description",
16-
"sha" : "18f3e63d05582537db6d183d9d557be09e1f90c8",
17-
"target_url" : "https://gitlab.example.com/thedude/gitlab-ce/builds/91",
18-
"finished_at" : "2016-01-19T08:40:25.934Z",
19-
"id" : 2148826854,
20-
"ref" : "master"
21-
}
2+
"id": 78919,
3+
"sha": "6b9fec60e107f1f323dfa6674b317facd996cb0a",
4+
"ref": "cccct",
5+
"status": "failed",
6+
"name": "extci",
7+
"target_url": "https://example.com/ext/6b9fec60e107f1f323dfa6674b317facd996cb0a/",
8+
"description": "External check",
9+
"created_at": "2023-04-03T11:05:27.792Z",
10+
"started_at": "2023-04-03T11:05:29.205Z",
11+
"finished_at": "2023-04-03T11:16:05.803Z",
12+
"allow_failure": false,
13+
"coverage": 10.8,
14+
"pipeline_id": 15641,
15+
"author": {
16+
"id": 7,
17+
"name": "Pamella Huel",
18+
"username": "arnita",
19+
"state": "active",
20+
"avatar_url": "http://www.gravatar.com/avatar/a2f5c6fcef64c9c69cb8779cb292be1b?s=80&d=identicon",
21+
"web_url": "http://gitlab.example.com/arnita"
22+
}
23+
}

0 commit comments

Comments
 (0)