Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
0f413e28
Unverified
Commit
0f413e28
authored
Jul 05, 2021
by
Gautier de Saint Martin Lacaze
Committed by
GitHub
Jul 05, 2021
Browse files
Merge pull request #726 from gitlab4j/issue-645-add-pipeline-id-in-commit-status
Fix #645 : Add pipeline_id in POST CommitStatus
parents
39de07d8
24b709f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/CommitsApi.java
View file @
0f413e28
...
@@ -498,7 +498,7 @@ public class CommitsApi extends AbstractApi {
...
@@ -498,7 +498,7 @@ public class CommitsApi extends AbstractApi {
MultivaluedMap
<
String
,
String
>
queryParams
=
(
filter
!=
null
?
MultivaluedMap
<
String
,
String
>
queryParams
=
(
filter
!=
null
?
filter
.
getQueryParams
(
page
,
perPage
).
asMap
()
:
getPageQueryParams
(
page
,
perPage
));
filter
.
getQueryParams
(
page
,
perPage
).
asMap
()
:
getPageQueryParams
(
page
,
perPage
));
Response
response
=
get
(
Response
.
Status
.
OK
,
queryParams
,
Response
response
=
get
(
Response
.
Status
.
OK
,
queryParams
,
"projects"
,
this
.
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"commits"
,
sha
,
"statuses"
);
"projects"
,
this
.
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"commits"
,
sha
,
"statuses"
);
return
(
response
.
readEntity
(
new
GenericType
<
List
<
CommitStatus
>>()
{}));
return
(
response
.
readEntity
(
new
GenericType
<
List
<
CommitStatus
>>()
{}));
}
}
...
@@ -515,7 +515,7 @@ public class CommitsApi extends AbstractApi {
...
@@ -515,7 +515,7 @@ public class CommitsApi extends AbstractApi {
* @return a Pager containing the commit statuses for the specified project and sha that meet the provided filter
* @return a Pager containing the commit statuses for the specified project and sha that meet the provided filter
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
*/
public
Pager
<
CommitStatus
>
getCommitStatuses
(
Object
projectIdOrPath
,
String
sha
,
public
Pager
<
CommitStatus
>
getCommitStatuses
(
Object
projectIdOrPath
,
String
sha
,
CommitStatusFilter
filter
,
int
itemsPerPage
)
throws
GitLabApiException
{
CommitStatusFilter
filter
,
int
itemsPerPage
)
throws
GitLabApiException
{
if
(
projectIdOrPath
==
null
)
{
if
(
projectIdOrPath
==
null
)
{
...
@@ -567,6 +567,31 @@ public class CommitsApi extends AbstractApi {
...
@@ -567,6 +567,31 @@ public class CommitsApi extends AbstractApi {
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
* @throws GitLabApiException GitLabApiException if any exception occurs during execution
*/
*/
public
CommitStatus
addCommitStatus
(
Object
projectIdOrPath
,
String
sha
,
CommitBuildState
state
,
CommitStatus
status
)
throws
GitLabApiException
{
public
CommitStatus
addCommitStatus
(
Object
projectIdOrPath
,
String
sha
,
CommitBuildState
state
,
CommitStatus
status
)
throws
GitLabApiException
{
return
addCommitStatus
(
projectIdOrPath
,
sha
,
state
,
null
,
status
);
}
/**
* <p>Add or update the build status of a commit. The following fluent methods are available on the
* CommitStatus instance for setting up the status:</p>
* <pre><code>
* withCoverage(Float)
* withDescription(String)
* withName(String)
* withRef(String)
* withTargetUrl(String)
* </code></pre>
*
* <pre><code>GitLab Endpoint: POST /projects/:id/statuses/:sha</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance (required)
* @param sha a commit SHA (required)
* @param state the state of the status. Can be one of the following: PENDING, RUNNING, SUCCESS, FAILED, CANCELED (required)
* @param pipelineId The ID of the pipeline to set status. Use in case of several pipeline on same SHA (optional)
* @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
*/
public
CommitStatus
addCommitStatus
(
Object
projectIdOrPath
,
String
sha
,
CommitBuildState
state
,
Integer
pipelineId
,
CommitStatus
status
)
throws
GitLabApiException
{
if
(
projectIdOrPath
==
null
)
{
if
(
projectIdOrPath
==
null
)
{
throw
new
RuntimeException
(
"projectIdOrPath cannot be null"
);
throw
new
RuntimeException
(
"projectIdOrPath cannot be null"
);
...
@@ -585,6 +610,10 @@ public class CommitsApi extends AbstractApi {
...
@@ -585,6 +610,10 @@ public class CommitsApi extends AbstractApi {
.
withParam
(
"coverage"
,
status
.
getCoverage
());
.
withParam
(
"coverage"
,
status
.
getCoverage
());
}
}
if
(
pipelineId
!=
null
)
{
formData
.
withParam
(
"pipeline_id"
,
pipelineId
);
}
Response
response
=
post
(
Response
.
Status
.
OK
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"statuses"
,
sha
);
Response
response
=
post
(
Response
.
Status
.
OK
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"statuses"
,
sha
);
return
(
response
.
readEntity
(
CommitStatus
.
class
));
return
(
response
.
readEntity
(
CommitStatus
.
class
));
}
}
...
@@ -837,7 +866,7 @@ public class CommitsApi extends AbstractApi {
...
@@ -837,7 +866,7 @@ public class CommitsApi extends AbstractApi {
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"commits"
,
sha
,
"revert"
);
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"repository"
,
"commits"
,
sha
,
"revert"
);
return
(
response
.
readEntity
(
Commit
.
class
));
return
(
response
.
readEntity
(
Commit
.
class
));
}
}
/**
/**
* Cherry picks a commit in a given branch.
* Cherry picks a commit in a given branch.
*
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment