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
67376431
Commit
67376431
authored
Sep 18, 2018
by
Steve Azzopardi
Committed by
Kamil Trzciński
Sep 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose runners status information in job api
parent
953018e3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
7 deletions
+88
-7
app/helpers/ci_status_helper.rb
app/helpers/ci_status_helper.rb
+0
-5
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+18
-0
app/views/projects/jobs/show.html.haml
app/views/projects/jobs/show.html.haml
+1
-1
changelogs/unreleased/51273-expose-runners-for-build-in-job-api.yml
.../unreleased/51273-expose-runners-for-build-in-job-api.yml
+5
-0
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+49
-0
spec/fixtures/api/schemas/job/job_details.json
spec/fixtures/api/schemas/job/job_details.json
+2
-1
spec/fixtures/api/schemas/job/runners.json
spec/fixtures/api/schemas/job/runners.json
+13
-0
No files found.
app/helpers/ci_status_helper.rb
View file @
67376431
...
@@ -123,11 +123,6 @@ module CiStatusHelper
...
@@ -123,11 +123,6 @@ module CiStatusHelper
render_status_with_link
(
'pipeline'
,
pipeline
.
status
,
path
,
tooltip_placement:
tooltip_placement
)
render_status_with_link
(
'pipeline'
,
pipeline
.
status
,
path
,
tooltip_placement:
tooltip_placement
)
end
end
def
no_runners_for_project?
(
project
)
project
.
runners
.
blank?
&&
Ci
::
Runner
.
instance_type
.
blank?
end
def
render_status_with_link
(
type
,
status
,
path
=
nil
,
tooltip_placement:
'left'
,
cssclass:
''
,
container:
'body'
,
icon_size:
16
)
def
render_status_with_link
(
type
,
status
,
path
=
nil
,
tooltip_placement:
'left'
,
cssclass:
''
,
container:
'body'
,
icon_size:
16
)
klass
=
"ci-status-link ci-status-icon-
#{
status
.
dasherize
}
#{
cssclass
}
"
klass
=
"ci-status-link ci-status-icon-
#{
status
.
dasherize
}
#{
cssclass
}
"
title
=
"
#{
type
.
titleize
}
:
#{
ci_label_for_status
(
status
)
}
"
title
=
"
#{
type
.
titleize
}
:
#{
ci_label_for_status
(
status
)
}
"
...
...
app/serializers/build_details_entity.rb
View file @
67376431
...
@@ -79,6 +79,20 @@ class BuildDetailsEntity < JobEntity
...
@@ -79,6 +79,20 @@ class BuildDetailsEntity < JobEntity
expose
:trigger_variables
,
as: :variables
,
using:
TriggerVariableEntity
expose
:trigger_variables
,
as: :variables
,
using:
TriggerVariableEntity
end
end
expose
:runners
do
expose
:online
do
|
build
|
build
.
any_runners_online?
end
expose
:available
do
|
build
|
project
.
any_runners?
end
expose
:settings_path
,
if:
->
(
*
)
{
can_admin_build?
}
do
|
build
|
project_runners_path
(
project
)
end
end
private
private
def
build_failed_issue_options
def
build_failed_issue_options
...
@@ -97,4 +111,8 @@ class BuildDetailsEntity < JobEntity
...
@@ -97,4 +111,8 @@ class BuildDetailsEntity < JobEntity
def
can_create_build_terminal?
def
can_create_build_terminal?
can?
(
current_user
,
:create_build_terminal
,
build
)
&&
build
.
has_terminal?
can?
(
current_user
,
:create_build_terminal
,
build
)
&&
build
.
has_terminal?
end
end
def
can_admin_build?
can?
(
request
.
current_user
,
:admin_build
,
project
)
end
end
end
app/views/projects/jobs/show.html.haml
View file @
67376431
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
-
unless
@build
.
any_runners_online?
-
unless
@build
.
any_runners_online?
.bs-callout.bs-callout-warning.js-build-stuck
.bs-callout.bs-callout-warning.js-build-stuck
%p
%p
-
if
no_runners_for_project?
(
@build
.
project
)
-
if
@project
.
any_runners?
This job is stuck, because the project doesn't have any runners online assigned to it.
This job is stuck, because the project doesn't have any runners online assigned to it.
-
elsif
@build
.
tags
.
any?
-
elsif
@build
.
tags
.
any?
This job is stuck, because you don't have any active runners online with any of these tags assigned to them:
This job is stuck, because you don't have any active runners online with any of these tags assigned to them:
...
...
changelogs/unreleased/51273-expose-runners-for-build-in-job-api.yml
0 → 100644
View file @
67376431
---
title
:
Expose project runners in job API
merge_request
:
21618
author
:
type
:
other
spec/controllers/projects/jobs_controller_spec.rb
View file @
67376431
...
@@ -288,6 +288,55 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
...
@@ -288,6 +288,55 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
end
end
end
end
context
'when no runners are available'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
,
active:
false
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
it
'exposes needed information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
expect
(
json_response
[
'runners'
][
'available'
]).
to
be
false
end
end
context
'when no runner is online'
do
let
(
:runner
)
{
create
(
:ci_runner
,
:instance
)
}
let
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
runner:
runner
)
}
it
'exposes needed information'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'online'
]).
to
be
false
expect
(
json_response
[
'runners'
][
'available'
]).
to
be
true
end
end
context
'settings_path'
do
context
'when user is developer'
do
it
'settings_path is not available'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
]).
not_to
have_key
(
'settings_path'
)
end
end
context
'when user is maintainer'
do
let
(
:user
)
{
create
(
:user
,
:admin
)
}
before
do
project
.
add_maintainer
(
user
)
sign_in
(
user
)
end
it
'settings_path is available'
do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'job/job_details'
)
expect
(
json_response
[
'runners'
][
'settings_path'
]).
to
match
(
/runners/
)
end
end
end
end
end
context
'when requesting JSON job is triggered'
do
context
'when requesting JSON job is triggered'
do
...
...
spec/fixtures/api/schemas/job/job_details.json
View file @
67376431
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
"terminal_path"
:
{
"type"
:
"string"
},
"terminal_path"
:
{
"type"
:
"string"
},
"trigger"
:
{
"$ref"
:
"trigger.json"
},
"trigger"
:
{
"$ref"
:
"trigger.json"
},
"deployment_status"
:
{
"$ref"
:
"deployment_status.json"
},
"deployment_status"
:
{
"$ref"
:
"deployment_status.json"
},
"runner"
:
{
"$ref"
:
"runner.json"
}
"runner"
:
{
"$ref"
:
"runner.json"
},
"runners"
:
{
"type"
:
"runners.json"
}
}
}
}
}
spec/fixtures/api/schemas/job/runners.json
0 → 100644
View file @
67376431
{
"type"
:
"object"
,
"required"
:
[
"online"
,
"available"
],
"properties"
:
{
"online"
:
{
"type"
:
"boolean"
},
"available"
:
{
"type"
:
"boolean"
},
"settings_path"
:
{
"type"
:
"string"
}
},
"additionalProperties"
:
false
}
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