2018-09-11 19:08:34 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-26 16:31:05 +00:00
|
|
|
module Types
|
|
|
|
module Ci
|
|
|
|
class PipelineType < BaseObject
|
|
|
|
graphql_name 'Pipeline'
|
|
|
|
|
2020-08-13 18:10:36 +00:00
|
|
|
connection_type_class(Types::CountableConnectionType)
|
|
|
|
|
2019-03-04 02:30:32 +00:00
|
|
|
authorize :read_pipeline
|
2021-02-02 12:10:15 +00:00
|
|
|
present_using ::Ci::PipelinePresenter
|
2019-03-04 02:30:32 +00:00
|
|
|
|
|
|
|
expose_permissions Types::PermissionTypes::Ci::Pipeline
|
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :id, GraphQL::ID_TYPE, null: false,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'ID of the pipeline.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-03-16 15:09:27 +00:00
|
|
|
field :iid, GraphQL::STRING_TYPE, null: false,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Internal ID of the pipeline.'
|
2018-06-26 16:31:05 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :sha, GraphQL::STRING_TYPE, null: false,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: "SHA of the pipeline's commit."
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :before_sha, GraphQL::STRING_TYPE, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Base SHA of the source branch.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :status, PipelineStatusEnum, null: false,
|
|
|
|
description: "Status of the pipeline (#{::Ci::Pipeline.all_state_names.compact.join(', ').upcase})"
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :detailed_status, Types::Ci::DetailedStatusType, null: false,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Detailed status of the pipeline.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-08-18 09:10:05 +00:00
|
|
|
field :config_source, PipelineConfigSourceEnum, null: true,
|
2021-02-02 12:10:15 +00:00
|
|
|
description: "Configuration source of the pipeline (#{::Enums::Ci::Pipeline.config_sources.keys.join(', ').upcase})"
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :duration, GraphQL::INT_TYPE, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Duration of the pipeline in seconds.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :coverage, GraphQL::FLOAT_TYPE, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Coverage percentage.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :created_at, Types::TimeType, null: false,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: "Timestamp of the pipeline's creation."
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :updated_at, Types::TimeType, null: false,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: "Timestamp of the pipeline's last activity."
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :started_at, Types::TimeType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Timestamp when the pipeline was started.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :finished_at, Types::TimeType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: "Timestamp of the pipeline's completion."
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2019-12-19 06:08:05 +00:00
|
|
|
field :committed_at, Types::TimeType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: "Timestamp of the pipeline's commit."
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-08-11 15:10:08 +00:00
|
|
|
field :stages, Types::Ci::StageType.connection_type, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Stages of the pipeline.',
|
2020-08-11 15:10:08 +00:00
|
|
|
extras: [:lookahead],
|
|
|
|
resolver: Resolvers::Ci::PipelineStagesResolver
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-08-18 21:09:57 +00:00
|
|
|
field :user, Types::UserType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Pipeline user.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-09-11 09:08:44 +00:00
|
|
|
field :retryable, GraphQL::BOOLEAN_TYPE,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Specifies if a pipeline can be retried.',
|
2020-09-11 09:08:44 +00:00
|
|
|
method: :retryable?,
|
|
|
|
null: false
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-09-11 09:08:44 +00:00
|
|
|
field :cancelable, GraphQL::BOOLEAN_TYPE,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Specifies if a pipeline can be canceled.',
|
2020-09-11 09:08:44 +00:00
|
|
|
method: :cancelable?,
|
|
|
|
null: false
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-10-30 06:08:54 +00:00
|
|
|
field :jobs,
|
|
|
|
::Types::Ci::JobType.connection_type,
|
|
|
|
null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Jobs belonging to the pipeline.',
|
2020-11-17 21:09:19 +00:00
|
|
|
resolver: ::Resolvers::Ci::JobsResolver
|
|
|
|
|
2020-11-03 15:09:05 +00:00
|
|
|
field :source_job, Types::Ci::JobType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Job where pipeline was triggered from.'
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-11-03 15:09:05 +00:00
|
|
|
field :downstream, Types::Ci::PipelineType.connection_type, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Pipelines this pipeline will trigger.',
|
2020-11-03 15:09:05 +00:00
|
|
|
method: :triggered_pipelines_with_preloads
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-11-03 15:09:05 +00:00
|
|
|
field :upstream, Types::Ci::PipelineType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Pipeline that triggered the pipeline.',
|
2020-11-03 15:09:05 +00:00
|
|
|
method: :triggered_by_pipeline
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-11-03 15:09:05 +00:00
|
|
|
field :path, GraphQL::STRING_TYPE, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: "Relative path to the pipeline's page."
|
2020-11-17 21:09:19 +00:00
|
|
|
|
2020-11-03 15:09:05 +00:00
|
|
|
field :project, Types::ProjectType, null: true,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Project the pipeline belongs to.'
|
2020-12-01 12:09:17 +00:00
|
|
|
|
2020-12-09 18:09:48 +00:00
|
|
|
field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?,
|
2021-01-22 21:09:10 +00:00
|
|
|
description: 'Indicates if the pipeline is active.'
|
2020-12-09 18:09:48 +00:00
|
|
|
|
2020-12-01 12:09:17 +00:00
|
|
|
def detailed_status
|
|
|
|
object.detailed_status(context[:current_user])
|
|
|
|
end
|
|
|
|
|
|
|
|
def user
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find
|
|
|
|
end
|
|
|
|
|
|
|
|
def path
|
|
|
|
::Gitlab::Routing.url_helpers.project_pipeline_path(object.project, object)
|
|
|
|
end
|
2018-06-26 16:31:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-06-15 18:08:43 +00:00
|
|
|
|
|
|
|
Types::Ci::PipelineType.prepend_if_ee('::EE::Types::Ci::PipelineType')
|