summaryrefslogtreecommitdiff
path: root/app/serializers/build_details_entity.rb
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/serializers/build_details_entity.rb
parent953018e3d4b0bc101543218f4cdf235e1a9d51c8 (diff)
downloadgitlab-ce-673764319acfdefd416cbd228073bc48fe05b63d.tar.gz
Expose runners status information in job api
Diffstat (limited to 'app/serializers/build_details_entity.rb')
-rw-r--r--app/serializers/build_details_entity.rb18
1 files changed, 18 insertions, 0 deletions
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