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
7f4236ca
Commit
7f4236ca
authored
Jul 27, 2021
by
Jeroen Muis
Committed by
charlie ablett
Jul 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test report summary resource to the GitLab pipeline API (v4)
parent
1c75f317
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
0 deletions
+105
-0
doc/api/pipelines.md
doc/api/pipelines.md
+53
-0
lib/api/ci/pipelines.rb
lib/api/ci/pipelines.rb
+13
-0
spec/requests/api/ci/pipelines_spec.rb
spec/requests/api/ci/pipelines_spec.rb
+39
-0
No files found.
doc/api/pipelines.md
View file @
7f4236ca
...
...
@@ -207,6 +207,59 @@ Sample response:
}
```
### Get a pipeline's test report summary
> Introduced in [GitLab 14.2](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65471)
NOTE:
This API route is part of the
[
Unit test report
](
../ci/unit_test_reports.md
)
feature.
```
plaintext
GET /projects/:id/pipelines/:pipeline_id/test_report_summary
```
| Attribute | Type | Required | Description |
|------------|---------|----------|---------------------|
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
index.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`pipeline_id`
| integer | yes | The ID of a pipeline |
Sample request:
```
shell
curl
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/1/pipelines/46/test_report_summary"
```
Sample response:
```
json
{
"total"
:
{
"time"
:
1904
,
"count"
:
3363
,
"success"
:
3351
,
"failed"
:
0
,
"skipped"
:
12
,
"error"
:
0
,
"suite_error"
:
null
},
"test_suites"
:
[
{
"name"
:
"test"
,
"total_time"
:
1904
,
"total_count"
:
3363
,
"success_count"
:
3351
,
"failed_count"
:
0
,
"skipped_count"
:
12
,
"error_count"
:
0
,
"build_ids"
:
[
66004
],
"suite_error"
:
null
}
]
}
```
## Create a new pipeline
```
plaintext
...
...
lib/api/ci/pipelines.rb
View file @
7f4236ca
...
...
@@ -187,6 +187,19 @@ module API
present
pipeline
.
test_reports
,
with:
TestReportEntity
,
details:
true
end
desc
'Gets the test report summary for a given pipeline'
do
detail
'This feature was introduced in GitLab 14.2'
success
TestReportSummaryEntity
end
params
do
requires
:pipeline_id
,
type:
Integer
,
desc:
'The pipeline ID'
end
get
':id/pipelines/:pipeline_id/test_report_summary'
do
authorize!
:read_build
,
pipeline
present
pipeline
.
test_report_summary
,
with:
TestReportSummaryEntity
end
desc
'Deletes a pipeline'
do
detail
'This feature was introduced in GitLab 11.6'
http_codes
[[
204
,
'Pipeline was deleted'
],
[
403
,
'Forbidden'
]]
...
...
spec/requests/api/ci/pipelines_spec.rb
View file @
7f4236ca
...
...
@@ -1150,4 +1150,43 @@ RSpec.describe API::Ci::Pipelines do
end
end
end
describe
'GET /projects/:id/pipelines/:pipeline_id/test_report_summary'
do
subject
{
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/test_report_summary"
,
current_user
)
}
context
'authorized user'
do
let
(
:current_user
)
{
user
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when pipeline does not have a test report summary'
do
it
'returns an empty test report summary'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'total'
][
'count'
]).
to
eq
(
0
)
end
end
context
'when pipeline has a test report summary'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:with_report_results
,
project:
project
)
}
it
'returns the test report summary'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'total'
][
'count'
]).
to
eq
(
2
)
end
end
end
context
'unauthorized user'
do
it
'does not return project pipelines'
do
get
api
(
"/projects/
#{
project
.
id
}
/pipelines/
#{
pipeline
.
id
}
/test_report_summary"
,
non_member
)
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
expect
(
json_response
[
'message'
]).
to
eq
'404 Project Not Found'
end
end
end
end
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