Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
fd88b0ca
Commit
fd88b0ca
authored
Nov 16, 2017
by
Tony Rom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `pipelines` endpoint to merge requests API
parent
627a9687
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
0 deletions
+87
-0
changelogs/unreleased/39214__pipeline_api.yml
changelogs/unreleased/39214__pipeline_api.yml
+5
-0
doc/api/merge_requests.md
doc/api/merge_requests.md
+26
-0
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+15
-0
spec/fixtures/api/schemas/public_api/v4/pipelines.json
spec/fixtures/api/schemas/public_api/v4/pipelines.json
+4
-0
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+37
-0
No files found.
changelogs/unreleased/39214__pipeline_api.yml
0 → 100644
View file @
fd88b0ca
---
title
:
Add `pipelines` endpoint to merge requests API
merge_request
:
15454
author
:
Tony Rom <thetonyrom@gmail.com>
type
:
added
doc/api/merge_requests.md
View file @
fd88b0ca
...
@@ -431,6 +431,32 @@ Parameters:
...
@@ -431,6 +431,32 @@ Parameters:
}
}
```
```
## List MR pipelines
Get a list of merge request pipelines.
```
GET /projects/:id/merge_requests/:merge_request_iid/pipelines
```
Parameters:
-
`id`
(required) - The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user
-
`merge_request_iid`
(required) - The internal ID of the merge request
Example of response
```
json
[
{
"id"
:
77
,
"sha"
:
"959e04d7c7a30600c894bd3c0cd0e1ce7f42c11d"
,
"ref"
:
"master"
,
"status"
:
"success"
}
]
```
## Create MR
## Create MR
Creates a new merge request.
Creates a new merge request.
...
...
lib/api/merge_requests.rb
View file @
fd88b0ca
...
@@ -24,6 +24,12 @@ module API
...
@@ -24,6 +24,12 @@ module API
.
preload
(
:notes
,
:author
,
:assignee
,
:milestone
,
:latest_merge_request_diff
,
:labels
,
:timelogs
)
.
preload
(
:notes
,
:author
,
:assignee
,
:milestone
,
:latest_merge_request_diff
,
:labels
,
:timelogs
)
end
end
def
merge_request_pipelines_with_access
(
access_level
=
:read_pipeline
)
authorize!
access_level
,
user_project
mr
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
mr
.
all_pipelines
end
params
:merge_requests_params
do
params
:merge_requests_params
do
optional
:state
,
type:
String
,
values:
%w[opened closed merged all]
,
default:
'all'
,
optional
:state
,
type:
String
,
values:
%w[opened closed merged all]
,
default:
'all'
,
desc:
'Return opened, closed, merged, or all merge requests'
desc:
'Return opened, closed, merged, or all merge requests'
...
@@ -203,6 +209,15 @@ module API
...
@@ -203,6 +209,15 @@ module API
present
merge_request
,
with:
Entities
::
MergeRequestChanges
,
current_user:
current_user
present
merge_request
,
with:
Entities
::
MergeRequestChanges
,
current_user:
current_user
end
end
desc
'Get the merge request pipelines'
do
success
Entities
::
PipelineBasic
end
get
':id/merge_requests/:merge_request_iid/pipelines'
do
pipelines
=
merge_request_pipelines_with_access
present
paginate
(
pipelines
),
with:
Entities
::
PipelineBasic
end
desc
'Update a merge request'
do
desc
'Update a merge request'
do
success
Entities
::
MergeRequest
success
Entities
::
MergeRequest
end
end
...
...
spec/fixtures/api/schemas/public_api/v4/pipelines.json
0 → 100644
View file @
fd88b0ca
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"pipeline/basic.json"
}
}
spec/requests/api/merge_requests_spec.rb
View file @
fd88b0ca
...
@@ -525,6 +525,43 @@ describe API::MergeRequests do
...
@@ -525,6 +525,43 @@ describe API::MergeRequests do
end
end
end
end
describe
'GET /projects/:id/merge_requests/:merge_request_iid/pipelines'
do
context
'when authorized'
do
let!
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
user:
user
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
)
}
let!
(
:pipeline2
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
it
'returns a paginated array of corresponding pipelines'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
pipeline
.
id
)
end
it
'exposes basic attributes'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/pipelines'
)
end
end
context
'when unauthorized'
do
it
'returns 403'
do
project
=
create
(
:project
,
public_builds:
false
)
merge_request
=
create
(
:merge_request
,
:simple
,
source_project:
project
)
guest
=
create
(
:user
)
project
.
team
<<
[
guest
,
:guest
]
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/pipelines"
,
guest
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
describe
"POST /projects/:id/merge_requests"
do
describe
"POST /projects/:id/merge_requests"
do
context
'between branches projects'
do
context
'between branches projects'
do
it
"returns merge_request"
do
it
"returns merge_request"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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