Skip to content
Snippets Groups Projects
Commit 0e06cfc0 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Add api points for ci cd status. Add favicon.

parent 3918c303
Branches
Tags
1 merge request!9561Expose CI/CD status API endpoints with Gitlab::Ci::Status facility on pipeline, job and merge request for favicon
Showing
with 68 additions and 2 deletions
Loading
@@ -91,6 +91,12 @@ class Projects::BuildsController < Projects::ApplicationController
Loading
@@ -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
Loading
Loading
Loading
@@ -10,7 +10,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -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]
Loading
@@ -473,6 +473,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
Loading
@@ -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
Loading
Loading
Loading
@@ -72,6 +72,12 @@ class Projects::PipelinesController < Projects::ApplicationController
Loading
@@ -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
Loading
Loading
Loading
@@ -19,6 +19,12 @@ class BuildEntity < Grape::Entity
Loading
@@ -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)
Loading
Loading
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
Loading
Loading
Loading
@@ -102,6 +102,7 @@ constraints(ProjectUrlConstrainer.new) do
Loading
@@ -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
Loading
@@ -152,6 +153,7 @@ constraints(ProjectUrlConstrainer.new) do
Loading
@@ -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
   
Loading
@@ -203,6 +205,7 @@ constraints(ProjectUrlConstrainer.new) do
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -13,6 +13,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
Loading
@@ -20,6 +20,10 @@ module Gitlab
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment