Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini committed Nov 18, 2023
2 parents c6108d8 + 906e79a commit 17412b4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
9 changes: 8 additions & 1 deletion src/main/java/org/gitlab4j/api/CommitsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;

Expand Down Expand Up @@ -590,7 +591,9 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu
* @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) {
Expand All @@ -607,7 +610,11 @@ public CommitStatus addCommitStatus(Object projectIdOrPath, String sha, CommitBu
.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) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/gitlab4j/api/models/CommitStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,6 +86,14 @@ public void setName(String name) {
this.name = name;
}

public Long getPipelineId() {
return pipelineId;
}

public void setPipelineId(Long pipelineId) {
this.pipelineId = pipelineId;
}

public String getRef() {
return ref;
}
Expand Down Expand Up @@ -140,6 +149,11 @@ public CommitStatus withName(String name) {
return this;
}

public CommitStatus withPipelineId(Long pipelineId) {
this.pipelineId = pipelineId;
return this;
}

public CommitStatus withRef(String ref) {
this.ref = ref;
return this;
Expand Down
42 changes: 22 additions & 20 deletions src/test/resources/org/gitlab4j/api/commit-status.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{
"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"
}
"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"
}
}

0 comments on commit 17412b4

Please sign in to comment.