Commit 0e06cfc0 authored by Shinya Maeda's avatar Shinya Maeda

Add api points for ci cd status. Add favicon.

parent 3918c303
...@@ -91,6 +91,12 @@ class Projects::BuildsController < Projects::ApplicationController ...@@ -91,6 +91,12 @@ class Projects::BuildsController < Projects::ApplicationController
end end
end end
def ci_cd_status
render json: BuildSerializer
.new(project: @project, user: @current_user)
.represent(@build)
end
private private
def build def build
......
...@@ -10,7 +10,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -10,7 +10,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :module_enabled before_action :module_enabled
before_action :merge_request, only: [ before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :merge_check, :edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :merge_check,
:ci_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues :ci_status, :ci_cd_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues
] ]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines] before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines]
before_action :define_show_vars, only: [:show, :diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines] before_action :define_show_vars, only: [:show, :diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines]
...@@ -473,6 +473,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -473,6 +473,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render json: response render json: response
end end
def ci_cd_status
render json: PipelineSerializer
.new(project: @project, user: @current_user)
.represent(@merge_request.head_pipeline)
end
def ci_environments_status def ci_environments_status
environments = environments =
begin begin
......
...@@ -72,6 +72,12 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -72,6 +72,12 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
end end
def ci_cd_status
render json: PipelineSerializer
.new(project: @project, user: @current_user)
.represent(@pipeline)
end
def stage def stage
@stage = pipeline.stage(params[:stage]) @stage = pipeline.stage(params[:stage])
return not_found unless @stage return not_found unless @stage
......
...@@ -19,6 +19,12 @@ class BuildEntity < Grape::Entity ...@@ -19,6 +19,12 @@ class BuildEntity < Grape::Entity
expose :created_at expose :created_at
expose :updated_at expose :updated_at
expose :status do |build, options|
StatusEntity.represent(
build.detailed_status(request.user),
options)
end
private private
def path_to(route, build) def path_to(route, build)
......
class BuildSerializer < BaseSerializer
entity BuildEntity
end
class StatusEntity < Grape::Entity class StatusEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
expose :icon, :text, :label, :group expose :icon, :favicon, :text, :label, :group
expose :has_details?, as: :has_details expose :has_details?, as: :has_details
expose :details_path expose :details_path
......
...@@ -102,6 +102,7 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -102,6 +102,7 @@ constraints(ProjectUrlConstrainer.new) do
get :merge_widget_refresh get :merge_widget_refresh
post :cancel_merge_when_pipeline_succeeds post :cancel_merge_when_pipeline_succeeds
get :ci_status get :ci_status
get :ci_cd_status
get :ci_environments_status get :ci_environments_status
post :toggle_subscription post :toggle_subscription
post :remove_wip post :remove_wip
...@@ -152,6 +153,7 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -152,6 +153,7 @@ constraints(ProjectUrlConstrainer.new) do
post :cancel post :cancel
post :retry post :retry
get :builds get :builds
get :ci_cd_status
end end
end end
...@@ -203,6 +205,7 @@ constraints(ProjectUrlConstrainer.new) do ...@@ -203,6 +205,7 @@ constraints(ProjectUrlConstrainer.new) do
post :erase post :erase
get :trace get :trace
get :raw get :raw
get :ci_cd_status
end end
resource :artifacts, only: [] do resource :artifacts, only: [] do
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
'icon_status_warning' 'icon_status_warning'
end end
def favicon
'build_status_warning'
end
def group def group
'failed_with_warnings' 'failed_with_warnings'
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_canceled' 'icon_status_canceled'
end end
def favicon
'build_status_canceled'
end
end end
end end
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_created' 'icon_status_created'
end end
def favicon
'build_status_created'
end
end end
end end
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_failed' 'icon_status_failed'
end end
def favicon
'build_status_failed'
end
end end
end end
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_pending' 'icon_status_pending'
end end
def favicon
'build_status_pending'
end
end end
end end
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_running' 'icon_status_running'
end end
def favicon
'build_status_running'
end
end end
end end
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_skipped' 'icon_status_skipped'
end end
def favicon
'build_status_skipped'
end
end end
end end
end end
......
...@@ -13,6 +13,10 @@ module Gitlab ...@@ -13,6 +13,10 @@ module Gitlab
def icon def icon
'icon_status_success' 'icon_status_success'
end end
def favicon
'build_status_success'
end
end end
end end
end end
......
...@@ -20,6 +20,10 @@ module Gitlab ...@@ -20,6 +20,10 @@ module Gitlab
'icon_status_warning' 'icon_status_warning'
end end
def favicon
'build_status_warning'
end
def group def group
'success_with_warnings' 'success_with_warnings'
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment