debian-mirror-gitlab/app/serializers/merge_requests/pipeline_entity.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.6 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
class MergeRequests::PipelineEntity < Grape::Entity
include RequestAwareEntity
expose :id
expose :active?, as: :active
2023-03-17 16:20:25 +05:30
expose :name
2020-10-24 23:57:45 +05:30
expose :path do |pipeline|
project_pipeline_path(pipeline.project, pipeline)
end
expose :flags do
2021-04-17 20:07:23 +05:30
expose :merged_result_pipeline?, as: :merge_request_pipeline
2020-10-24 23:57:45 +05:30
end
expose :commit, using: CommitEntity
expose :details do
2023-01-13 00:05:48 +05:30
expose :event_type_name do |pipeline|
pipeline.present.event_type_name
end
2021-03-08 18:12:59 +05:30
expose :artifacts do |pipeline, options|
rel = pipeline.downloadable_artifacts
if Feature.enabled?(:non_public_artifacts, type: :development)
2023-03-17 16:20:25 +05:30
rel = rel.select { |artifact| can?(request.current_user, :read_job_artifacts, artifact) }
2021-03-08 18:12:59 +05:30
end
2021-04-29 21:17:54 +05:30
BuildArtifactEntity.represent(rel, options.merge(project: pipeline.project))
2021-03-08 18:12:59 +05:30
end
2020-10-24 23:57:45 +05:30
expose :detailed_status, as: :status, with: DetailedStatusEntity do |pipeline|
pipeline.detailed_status(request.current_user)
end
expose :stages, using: StageEntity
2021-04-29 21:17:54 +05:30
expose :finished_at
2020-10-24 23:57:45 +05:30
end
# Coverage isn't always necessary (e.g. when displaying project pipelines in
# the UI). Instead of creating an entirely different entity we just allow the
# disabling of this specific field whenever necessary.
2022-01-26 12:08:38 +05:30
expose :coverage, unless: proc { options[:disable_coverage] } do |pipeline|
pipeline.present.coverage
end
2020-10-24 23:57:45 +05:30
expose :ref do
expose :branch?, as: :branch
end
expose :triggered_by_pipeline, as: :triggered_by, with: TriggeredPipelineEntity
expose :triggered_pipelines, as: :triggered, using: TriggeredPipelineEntity
end