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
c80abb40
Commit
c80abb40
authored
Sep 06, 2018
by
Steve Azzopardi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add retried jobs to pipeline stages
closes
https://gitlab.com/gitlab-org/gitlab-ce/issues/50461
parent
c7d1eef6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
12 deletions
+61
-12
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+1
-1
app/serializers/stage_entity.rb
app/serializers/stage_entity.rb
+16
-0
changelogs/unreleased/50461-add-retried-builds-in-pipeline-stage-endpoint.yml
...d/50461-add-retried-builds-in-pipeline-stage-endpoint.yml
+5
-0
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+31
-10
spec/fixtures/api/schemas/job/job.json
spec/fixtures/api/schemas/job/job.json
+3
-1
spec/fixtures/api/schemas/pipeline_stage.json
spec/fixtures/api/schemas/pipeline_stage.json
+5
-0
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
c80abb40
...
...
@@ -96,7 +96,7 @@ class Projects::PipelinesController < Projects::ApplicationController
render
json:
StageSerializer
.
new
(
project:
@project
,
current_user:
@current_user
)
.
represent
(
@stage
,
details:
true
)
.
represent
(
@stage
,
details:
true
,
retried:
params
[
:retried
]
)
end
# TODO: This endpoint is used by mini-pipeline-graph
...
...
app/serializers/stage_entity.rb
View file @
c80abb40
...
...
@@ -19,6 +19,12 @@ class StageEntity < Grape::Entity
latest_statuses
end
expose
:retried
,
if:
->
(
_
,
opts
)
{
opts
[
:retried
]
},
with:
JobEntity
do
|
stage
|
retried_statuses
end
expose
:detailed_status
,
as: :status
,
with:
DetailedStatusEntity
expose
:path
do
|
stage
|
...
...
@@ -48,9 +54,19 @@ class StageEntity < Grape::Entity
@grouped_statuses
||=
stage
.
statuses
.
latest_ordered
.
group_by
(
&
:status
)
end
def
grouped_retried_statuses
@grouped_retried_statuses
||=
stage
.
statuses
.
retried_ordered
.
group_by
(
&
:status
)
end
def
latest_statuses
HasStatus
::
ORDERED_STATUSES
.
map
do
|
ordered_status
|
grouped_statuses
.
fetch
(
ordered_status
,
[])
end
.
flatten
end
def
retried_statuses
HasStatus
::
ORDERED_STATUSES
.
map
do
|
ordered_status
|
grouped_retried_statuses
.
fetch
(
ordered_status
,
[])
end
.
flatten
end
end
changelogs/unreleased/50461-add-retried-builds-in-pipeline-stage-endpoint.yml
0 → 100644
View file @
c80abb40
---
title
:
Add retried jobs to pipeline stage
merge_request
:
21558
author
:
type
:
other
spec/controllers/projects/pipelines_controller_spec.rb
View file @
c80abb40
...
...
@@ -193,14 +193,34 @@ describe Projects::PipelinesController do
context
'when accessing existing stage'
do
before
do
create
(
:ci_build
,
:retried
,
:failed
,
pipeline:
pipeline
,
stage:
'build'
)
create
(
:ci_build
,
pipeline:
pipeline
,
stage:
'build'
)
end
context
'without retried'
do
before
do
get_stage
(
'build'
)
end
get_stage
(
'build'
)
it
'returns pipeline jobs without the retried builds'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'pipeline_stage'
)
expect
(
json_response
[
'latest_statuses'
].
length
).
to
eq
1
expect
(
json_response
).
not_to
have_key
(
'retried'
)
end
end
it
'returns html source for stage dropdown'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'pipeline_stage'
)
context
'with retried'
do
before
do
get_stage
(
'build'
,
retried:
true
)
end
it
'returns pipelines jobs with the retried builds'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'pipeline_stage'
)
expect
(
json_response
[
'latest_statuses'
].
length
).
to
eq
1
expect
(
json_response
[
'retried'
].
length
).
to
eq
1
end
end
end
...
...
@@ -214,12 +234,13 @@ describe Projects::PipelinesController do
end
end
def
get_stage
(
name
)
get
:stage
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
pipeline
.
id
,
stage:
name
,
format: :json
def
get_stage
(
name
,
params
=
{})
get
:stage
,
**
params
.
merge
(
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
pipeline
.
id
,
stage:
name
,
format: :json
)
end
end
...
...
spec/fixtures/api/schemas/job/job.json
View file @
c80abb40
...
...
@@ -25,7 +25,9 @@
"playable"
:
{
"type"
:
"boolean"
},
"created_at"
:
{
"type"
:
"string"
},
"updated_at"
:
{
"type"
:
"string"
},
"status"
:
{
"$ref"
:
"../status/ci_detailed_status.json"
}
"status"
:
{
"$ref"
:
"../status/ci_detailed_status.json"
},
"callout_message"
:
{
"type"
:
"string"
},
"recoverable"
:
{
"type"
:
"boolean"
}
},
"additionalProperties"
:
true
}
spec/fixtures/api/schemas/pipeline_stage.json
View file @
c80abb40
...
...
@@ -16,6 +16,11 @@
"items"
:
{
"$ref"
:
"job/job.json"
},
"optional"
:
true
},
"retried"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"job/job.json"
},
"optional"
:
true
},
"status"
:
{
"$ref"
:
"status/ci_detailed_status.json"
},
"path"
:
{
"type"
:
"string"
},
"dropdown_path"
:
{
"type"
:
"string"
}
...
...
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