summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSteve Azzopardi <sazzopardi@gitlab.com>2018-09-18 07:42:59 +0000
committerKamil TrzciƄski <ayufan@ayufan.eu>2018-09-18 07:42:59 +0000
commit673764319acfdefd416cbd228073bc48fe05b63d (patch)
tree361a6f3fa5bc2221db1ef48e54f66910457ed8d5 /app
parent953018e3d4b0bc101543218f4cdf235e1a9d51c8 (diff)
downloadgitlab-ce-673764319acfdefd416cbd228073bc48fe05b63d.tar.gz
Expose runners status information in job api
Diffstat (limited to 'app')
-rw-r--r--app/helpers/ci_status_helper.rb5
-rw-r--r--app/serializers/build_details_entity.rb18
-rw-r--r--app/views/projects/jobs/show.html.haml2
3 files changed, 19 insertions, 6 deletions
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index f8d36dce45d..136772e1ec3 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -123,11 +123,6 @@ module CiStatusHelper
render_status_with_link('pipeline', pipeline.status, path, tooltip_placement: tooltip_placement)
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)
klass = "ci-status-link ci-status-icon-#{status.dasherize} #{cssclass}"
title = "#{type.titleize}: #{ci_label_for_status(status)}"
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index ab9861c58c4..00a441a9a1e 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -79,6 +79,20 @@ class BuildDetailsEntity < JobEntity
expose :trigger_variables, as: :variables, using: TriggerVariableEntity
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
def build_failed_issue_options
@@ -97,4 +111,8 @@ class BuildDetailsEntity < JobEntity
def can_create_build_terminal?
can?(current_user, :create_build_terminal, build) && build.has_terminal?
end
+
+ def can_admin_build?
+ can?(request.current_user, :admin_build, project)
+ end
end
diff --git a/app/views/projects/jobs/show.html.haml b/app/views/projects/jobs/show.html.haml
index 078f40c4477..cf8d42976f8 100644
--- a/app/views/projects/jobs/show.html.haml
+++ b/app/views/projects/jobs/show.html.haml
@@ -10,7 +10,7 @@
- unless @build.any_runners_online?
.bs-callout.bs-callout-warning.js-build-stuck
%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.
- 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: