2016-11-10 09:32:23 -05:00
|
|
|
class PipelineEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
|
|
|
|
expose :id
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :user, using: UserEntity
|
2016-11-10 15:16:54 -05:00
|
|
|
|
2016-12-15 09:57:35 -05:00
|
|
|
expose :path do |pipeline|
|
2016-11-10 12:15:16 -05:00
|
|
|
namespace_project_pipeline_path(
|
|
|
|
pipeline.project.namespace,
|
|
|
|
pipeline.project,
|
|
|
|
pipeline)
|
|
|
|
end
|
2016-11-10 09:32:23 -05:00
|
|
|
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :details do
|
2016-12-15 09:57:35 -05:00
|
|
|
expose :status do |pipeline, options|
|
|
|
|
StatusEntity.represent(
|
|
|
|
pipeline.detailed_status(request.user),
|
|
|
|
options)
|
|
|
|
end
|
|
|
|
|
2016-11-10 11:50:55 -05:00
|
|
|
expose :duration
|
|
|
|
expose :finished_at
|
2016-12-09 15:56:12 -05:00
|
|
|
expose :stages, using: PipelineStageEntity
|
2016-11-10 11:50:55 -05:00
|
|
|
expose :artifacts, using: PipelineArtifactEntity
|
|
|
|
expose :manual_actions, using: PipelineActionEntity
|
|
|
|
end
|
2016-11-10 09:32:23 -05:00
|
|
|
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :flags do
|
2016-11-10 09:32:23 -05:00
|
|
|
expose :latest?, as: :latest
|
|
|
|
expose :triggered?, as: :triggered
|
2016-11-10 15:16:54 -05:00
|
|
|
|
2016-11-10 09:32:23 -05:00
|
|
|
expose :yaml_errors?, as: :yaml_errors do |pipeline|
|
|
|
|
pipeline.yaml_errors.present?
|
|
|
|
end
|
2016-11-10 15:16:54 -05:00
|
|
|
|
2016-12-15 16:06:39 -05:00
|
|
|
expose :stuck?, as: :stuck
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|
|
|
|
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :ref do
|
2016-11-10 09:32:23 -05:00
|
|
|
expose :name do |pipeline|
|
|
|
|
pipeline.ref
|
|
|
|
end
|
|
|
|
|
2016-11-10 12:15:16 -05:00
|
|
|
expose :url do |pipeline|
|
2016-11-10 09:32:23 -05:00
|
|
|
namespace_project_tree_url(
|
|
|
|
pipeline.project.namespace,
|
|
|
|
pipeline.project,
|
|
|
|
id: pipeline.ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :tag?
|
|
|
|
end
|
|
|
|
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :commit, using: CommitEntity
|
2016-11-10 09:32:23 -05:00
|
|
|
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :retry_url do |pipeline|
|
2016-11-10 15:16:54 -05:00
|
|
|
can?(request.user, :update_pipeline, pipeline.project) &&
|
2016-11-10 09:32:23 -05:00
|
|
|
pipeline.retryable? &&
|
2016-11-10 15:16:54 -05:00
|
|
|
retry_namespace_project_pipeline_path(pipeline.project.namespace,
|
|
|
|
pipeline.project, pipeline.id)
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|
|
|
|
|
2016-12-01 05:59:00 -05:00
|
|
|
expose :cancel_url do |pipeline|
|
2016-11-10 15:16:54 -05:00
|
|
|
can?(request.user, :update_pipeline, pipeline.project) &&
|
2016-11-10 09:32:23 -05:00
|
|
|
pipeline.cancelable? &&
|
2016-11-10 15:16:54 -05:00
|
|
|
cancel_namespace_project_pipeline_path(pipeline.project.namespace,
|
|
|
|
pipeline.project, pipeline.id)
|
|
|
|
end
|
|
|
|
|
2016-11-12 04:05:57 -05:00
|
|
|
expose :created_at, :updated_at
|
2016-11-10 09:32:23 -05:00
|
|
|
end
|