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
1ee18e9a
Commit
1ee18e9a
authored
Jan 23, 2020
by
Greg Messner
Browse files
Added support for merge request pipeline API calls (#500)
parent
becf6896
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/MergeRequestApi.java
View file @
1ee18e9a
...
...
@@ -19,6 +19,7 @@ import org.gitlab4j.api.models.MergeRequest;
import
org.gitlab4j.api.models.MergeRequestFilter
;
import
org.gitlab4j.api.models.MergeRequestParams
;
import
org.gitlab4j.api.models.Participant
;
import
org.gitlab4j.api.models.Pipeline
;
/**
* This class implements the client side API for the GitLab merge request calls.
...
...
@@ -1094,4 +1095,70 @@ public class MergeRequestApi extends AbstractApi {
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"merge_requests"
,
mergeRequestIid
);
return
(
response
.
readEntity
(
MergeRequest
.
class
));
}
/**
* Get a list of pipelines for a merge request.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a list containing the pipelines for the specified merge request
* @throws GitLabApiException if any exception occurs during execution
*/
public
List
<
Pipeline
>
getMergeRequestPipelines
(
Object
projectIdOrPath
,
Integer
mergeRequestIid
)
throws
GitLabApiException
{
return
(
getMergeRequestPipelines
(
projectIdOrPath
,
mergeRequestIid
,
getDefaultPerPage
()).
all
());
}
/**
* Get a Pager of pipelines for a merge request.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @param itemsPerPage the number of Pipeline instances that will be fetched per page
* @return a Pager containing the pipelines for the specified merge request
* @throws GitLabApiException if any exception occurs during execution
*/
public
Pager
<
Pipeline
>
getMergeRequestPipelines
(
Object
projectIdOrPath
,
Integer
mergeRequestIid
,
int
itemsPerPage
)
throws
GitLabApiException
{
return
(
new
Pager
<
Pipeline
>(
this
,
Pipeline
.
class
,
itemsPerPage
,
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"merge_requests"
,
mergeRequestIid
,
"pipelines"
));
}
/**
* Get a Stream of pipelines for a merge request.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a Stream containing the pipelines for the specified merge request
* @throws GitLabApiException if any exception occurs during execution
*/
public
Stream
<
Pipeline
>
getMergeRequestPipelinesStream
(
Object
projectIdOrPath
,
Integer
mergeRequestIid
)
throws
GitLabApiException
{
return
(
getMergeRequestPipelines
(
projectIdOrPath
,
mergeRequestIid
,
getDefaultPerPage
()).
stream
());
}
/**
* <p>Create a new pipeline for a merge request. A pipeline created via this endpoint will not run
* a regular branch/tag pipeline, it requires .gitlab-ci.yml to be configured with only:
* [merge_requests] to create jobs.</p>
*
* The new pipeline can be:
* A detached merge request pipeline.
* A pipeline for merged results if the project setting is enabled.
*
* <pre><code>GitLab Endpoint: POST /projects/:id/merge_requests/:merge_request_iid/pipelines</code></pre>
*
* @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance
* @param mergeRequestIid the internal ID of the merge request
* @return a Pipeline instance with the newly created pipeline info
* @throws GitLabApiException if any exception occurs during execution
*/
public
Pipeline
createMergeRequestPipeline
(
Object
projectIdOrPath
,
Integer
mergeRequestIid
)
throws
GitLabApiException
{
Response
response
=
post
(
Response
.
Status
.
CREATED
,
(
Form
)
null
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"merge_requests"
,
mergeRequestIid
,
"pipelines"
);
return
(
response
.
readEntity
(
Pipeline
.
class
));
}
}
src/main/java/org/gitlab4j/api/models/Pipeline.java
View file @
1ee18e9a
package
org.gitlab4j.api.models
;
import
java.util.Date
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.gitlab4j.api.utils.JacksonJson
;
...
...
@@ -15,10 +16,10 @@ public class Pipeline {
private
String
yamlErrors
;
private
User
user
;
private
Date
createdAt
;
private
Date
updated
_a
t
;
private
Date
started
_a
t
;
private
Date
finished
_a
t
;
private
Date
committed
_a
t
;
private
Date
updated
A
t
;
private
Date
started
A
t
;
private
Date
finished
A
t
;
private
Date
committed
A
t
;
private
String
coverage
;
private
Integer
duration
;
private
String
webUrl
;
...
...
@@ -96,36 +97,116 @@ public class Pipeline {
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updated_at
)
{
this
.
updatedAt
=
updated_at
;
}
public
Date
getStartedAt
()
{
return
startedAt
;
}
public
void
setStartedAt
(
Date
started_at
)
{
this
.
startedAt
=
started_at
;
}
public
Date
getFinishedAt
()
{
return
finishedAt
;
}
public
void
setFinishedAt
(
Date
finished_at
)
{
this
.
finishedAt
=
finished_at
;
}
public
Date
getCommittedAt
()
{
return
committedAt
;
}
public
void
setCommittedAt
(
Date
committed_at
)
{
this
.
committedAt
=
committed_at
;
}
/**
* @deprecated Replaced by {@link #getUpdatedAt()}
* @return the updated at Date
*/
@Deprecated
@JsonIgnore
public
Date
getUpdated_at
()
{
return
updated
_a
t
;
return
updated
A
t
;
}
public
void
setUpdated_at
(
Date
updated_at
)
{
this
.
updated_at
=
updated_at
;
/**
* @deprecated Replaced by {@link #setUpdatedAt(Date)}
* @param updatedAt new updated at value
*/
@Deprecated
@JsonIgnore
public
void
setUpdated_at
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
/**
* @deprecated Replaced by {@link #getStartedAt()}
* @return the started at Date
*/
@Deprecated
@JsonIgnore
public
Date
getStarted_at
()
{
return
started
_a
t
;
return
started
A
t
;
}
public
void
setStarted_at
(
Date
started_at
)
{
this
.
started_at
=
started_at
;
/**
* @deprecated Replaced by {@link #setStartedAt(Date)}
* @param startedAt new started at value
*/
@Deprecated
@JsonIgnore
public
void
setStarted_at
(
Date
startedAt
)
{
this
.
startedAt
=
startedAt
;
}
/**
* @deprecated Replaced by {@link #getFinishedAt()}
* @return the finished at Date
*/
@Deprecated
@JsonIgnore
public
Date
getFinished_at
()
{
return
finished
_a
t
;
return
finished
A
t
;
}
public
void
setFinished_at
(
Date
finished_at
)
{
this
.
finished_at
=
finished_at
;
/**
* @deprecated Replaced by {@link #setFinishedAt(Date)}
* @param finishedAt new finished at value
*/
@Deprecated
@JsonIgnore
public
void
setFinished_at
(
Date
finishedAt
)
{
this
.
finishedAt
=
finishedAt
;
}
/**
* @deprecated Replaced by {@link #getCommittedAt()}
* @return the committed at Date
*/
@Deprecated
@JsonIgnore
public
Date
getCommitted_at
()
{
return
committed
_a
t
;
return
committed
A
t
;
}
public
void
setCommitted_at
(
Date
committed_at
)
{
this
.
committed_at
=
committed_at
;
/**
* @deprecated Replaced by {@link #setCommittedAt(Date)}
* @param committedAt new committed at value
*/
@Deprecated
@JsonIgnore
public
void
setCommitted_at
(
Date
committedAt
)
{
this
.
committedAt
=
committedAt
;
}
public
String
getCoverage
()
{
...
...
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